Electric energy meter service scheduling method and electric energy meter
By introducing system modules and MessageID tables/NameID tables into the power meter software system, the problem of high code coupling in the power meter software system is solved, and the relative independence of business modules and simplification of code maintenance is achieved.
Patent Information
- Application Number
- CN202411447429.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-02-07
AI Technical Summary
When performing business scheduling of the power meter software system, the code coupling is high, which makes it difficult to understand and maintain logical relationships, and it is difficult to modify and transplant codes.
By establishing system modules in the software system of the power meter, each service module only transmits messages to the system module during interaction, and the system module executes related business logic. Use the MessageID table and the NameID table for message and data interaction to reduce the coupling between business modules.
It effectively reduces the code coupling between business modules, makes each business module relatively independent, and simplifies the code modification and porting process.
Smart Images

Figure CN119402464A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to an electric energy meter business dispatching method and an electric energy meter, belonging to the field of business dispatching of electric energy meter software systems. Background Art
[0002] The electric energy meter is an important terminal for realizing automatic collection of electricity consumption information, online interaction of metering information, and distributed energy settlement. With the development of digitalization, intelligence, and networking and the diversification of power demand on the user side, its functions and application scenarios are also constantly expanding. The electric energy meter has developed from a single metering and billing device to an intelligent electricity terminal that integrates multiple functions, including remote rate setting, remote refresh program, photovoltaic control, etc. However, with the advancement of technology and the growth of market demand, problems such as the manufacturing cost, technical threshold and market barriers of the electric energy meter have gradually emerged.
[0003] At present, when the software system of the electric energy meter performs task scheduling, the data transmission between business modules is carried out by global variable data transmission and direct function call, such as Figure 1 As shown, with the continuous increase in the business functions of the electric energy meter, the amount of code in this method is increasing, and the logical relationship between the business modules is gradually difficult for program developers to understand and maintain, and it is also very difficult to modify and transplant the code. Summary of the invention
[0004] The object of the present invention is to provide an electric energy meter service scheduling method and an electric energy meter, so as to solve the problem of high code coupling in the software system of the electric energy meter when performing service scheduling.
[0005] To achieve the above object, the solution of the present invention includes: The invention discloses an electric energy meter service dispatching method. When the service modules of the electric energy meter are used to realize the specific functions of the electric energy meter, the service module sending the message obtains the service name of the message sent by the corresponding service module when sending the message message through the MessageID table, and then sends the message message of the service name to the system module, and the system module sends the message message to other service modules, and then other service modules perform corresponding processing according to the needs; the MessageID table is used to store the service name of each service message of each service module; when the service modules are interacting with each other, the service module obtains the module data table name of the service module that wants to interact with the data through the NameID table, and then sends the system module a data request message including the obtained module data table name, and the system module finds the corresponding module data table according to the module data table name in the data request message, and then the system module executes the data processing logic corresponding to the data request message in the module data table; the NameID table is used to store the module data table name of the module data table of each service module, and the module data table is used to store the data of the corresponding service module, and the data request message includes a read data request message and a write data request message.
[0006] Furthermore, the MessageID table also includes the name of the message sent by the system module. The system module obtains the name of the message required by the system module when sending a message message through the MessageID table, sends the message message to each business module, and then the business module performs corresponding processing.
[0007] Furthermore, the system module sends a message message to the corresponding service module. After receiving the message message, if the service module has a code corresponding to the message message, it performs corresponding processing.
[0008] Furthermore, the business module or system module sends a message message to the system module or business module through the message dispatch interface of this module; the business module sends a read data request message to the system module through the read data interface of this module, and the system module reads the data in the module data table through the read data interface of this module; the business module sends a write data request message to the system module through the write data interface of this module, and the system module writes data to the module data table through the write data interface of this module; the message dispatch interface, read data interface and write data interface of the business module respectively inherit and rewrite the message dispatch interface, read data interface and write data interface of the system module.
[0009] Furthermore, the message message includes a synchronous message message or an asynchronous message message. When the system module receives a synchronous message message, the system module promptly sends the synchronous message message to the business module. When the system module receives an asynchronous message message, the system module waits until the next round of message processing to send an asynchronous message message to the business module.
[0010] The present invention discloses an electric energy meter, wherein the software system of the electric energy meter comprises a system module and various business modules for realizing specific functions of the electric energy meter, wherein the system module comprises a MessageID table for storing the business name of each business message of each business module and a NameID table for storing the module data table name of the module data table of each business module, wherein the module data table is used to store data of the corresponding business module; when message transmission is performed between various business modules, the business module sending the message obtains the business name of the message sent by the corresponding business module when sending the message message through the MessageID table, and then sends the message message of the business name to the system module, and the system module sends the message message to other business modules, and then the other business modules perform corresponding processing according to needs; when data interaction is performed between various business modules, the business module obtains the module data table name of the business module that wants to perform data interaction through the NameID table, and then sends a data request message including the obtained module data table name to the system module, and the system module finds the corresponding module data table according to the module data table name in the data request message, and then the system module executes the data processing logic corresponding to the data request message in the module data table; the data request message comprises a read data request message and a write data request message.
[0011] Furthermore, the MessageID table also includes the name of the message sent by the system module. The system module obtains the name of the message required by the system module when sending a message message through the MessageID table, sends the message message to each business module, and then the business module performs corresponding processing.
[0012] Furthermore, the system module sends a message message to the corresponding service module. After receiving the message message, if the service module has a code corresponding to the message message, it performs corresponding processing.
[0013] Furthermore, the business module or system module sends a message message to the system module or business module through the message dispatch interface of this module; the business module sends a read data request message to the system module through the read data interface of this module, and the system module reads the data in the module data table through the read data interface of this module; the business module sends a write data request message to the system module through the write data interface of this module, and the system module writes data to the module data table through the write data interface of this module; the message dispatch interface, read data interface and write data interface of the business module respectively inherit and rewrite the message dispatch interface, read data interface and write data interface of the system module.
[0014] Furthermore, the message message includes a synchronous message message or an asynchronous message message. When the system module receives a synchronous message message, the system module promptly sends the synchronous message message to the business module. When the system module receives an asynchronous message message, the system module waits until the next round of message processing to send an asynchronous message message to the business module.
[0015] The beneficial effects of the present invention are as follows: the present invention is a pioneering invention. When sending a message, the business module of the present invention obtains the business name of the message through the MessageID table, and then sends a message message to the system module, and the system module sends the message message to other business modules; when data is exchanged between business modules, the module data table name of the business module that wants to exchange data is obtained through the NameID table, and then a data request message including the obtained module data table name is sent to the system module, and the system module sends the data request message to other business modules. When the business module of the present invention performs business processing, each business module only interacts with the system module, and each business module is relatively independent, which effectively reduces the coupling of the code. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 It is a flowchart of task scheduling of an electric energy meter software system in the prior art; Figure 2 It is a flowchart of task scheduling of an electric energy meter software system of the present invention. DETAILED DESCRIPTION
[0017] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0018] The idea of the present invention is to establish a system module inside the software system of the electric energy meter. When each business module interacts, it only transmits corresponding messages to the system module, and the system module executes related business logic.
[0019] Method Example: This embodiment provides a method for dispatching electric energy meter services. Figure 2As shown, the business modules in the software system of the electric energy meter for realizing the specific functions of the electric energy meter include a display module for displaying electric energy, an electric energy module for measuring the electric energy consumed by the user, a communication module for communicating with the background control, a measurement module for collecting power-related parameters, a freezing module for freezing the remaining electric energy, a time module for recording important events occurring during the operation period of the electric energy meter system, a fee control module for controlling the electricity fee, and a control module for controlling the operation of the electric energy meter, and a system module is established. The system module includes a virtual function interface that allows the business module to inherit and override, that is, the business module is derived from the base class of the system module, and each business module also has a code for executing code related to its own business. Each business module is relatively independent, and each business module only interacts with the system module, and the system module executes the subsequent business logic.
[0020] During the initialization process of the system module, memory is allocated for the module object array, NameID table, and MessageID table of the system module, and the initial state is set. Among them, the module object array is used to store instances of business modules that have been registered with the system and the module data tables of the corresponding business modules, the NameID table is used to store the names of business modules and the names of the module data tables of the corresponding business modules, and the MessageID table is used to store the business names of business modules and system messages. Business modules and system modules obtain the names of the corresponding business modules, the names of the module data tables of the corresponding business modules, and the business names of messages sent by business modules and the system through the NameID table and the MessageID table.
[0021] Each business module registers this module into the system through module registration. Each business module registers this module into the system by calling the registration interface provided by the system module. During the registration process, the instance of this module will be added to the module object array of the system module, the NameID that uniquely corresponds to the name of this module and the NameID corresponding to the module data table of this module will be added to the NameID table, and the MessageID of this module when sending a message will be added to the MessageID table. Among them, the NameID table is the core for data reading and writing between business modules. The data type of the NameID table is an enumeration type, so as to establish the unique identification of the corresponding business module in the system. The MessageID table is the core for message dispatching between business modules. The data type of the MessageID table is an enumeration type, so as to establish the unique identification of the message corresponding to the business module in the system. During the data initialization process of the business module, its internal state will be initialized, including the definition of the module data table related to its own business function. The module data table is used to store persistent data in the EEPROM and data quickly accessed in the RAM, and then the module data table will be synchronously registered in the module object array.
[0022] When a business module needs to exchange data with other business modules, it sends a message packet including the MessageID of the message sent by this module to the system module through the message dispatching interface of this module, and the system module finds the business module that needs to respond to the message. Among them, the messages sent by the message dispatching interface include synchronous messages and asynchronous messages. Synchronous messages refer to messages sent to the system module, and the system module processes the messages in a timely manner. Asynchronous messages refer to messages sent to the system module, and the system module will not be executed until the next round of message processing after the program is executed. The message dispatching interface of the business module inherits and rewrites the message dispatching interface of the system module. Therefore, the system module itself will also send messages to each business module, and the MessageID table also contains the names of the messages sent by the system module.
[0023] When a business module needs to read data from other business modules, it sends a request message for reading data including the NameID of the module data table of the corresponding business module to the system through the read data interface of this module. The system module finds the module data table of the corresponding business module by accessing the module object array, and then reads the requested data from the module data table. The system module then sends the obtained data to the business module that requested to read the data. The read data interface of the business module inherits and overrides the read data interface of the system module.
[0024] When a business module needs to write data to other business modules, it sends a request message including the NameID of the module data table of the corresponding business module and the data to be written to the system through the write data interface of this module. The system module finds the module data table of the corresponding business module by accessing the module object array, and then writes the corresponding data to the module data table. Among them, the write data interface of the business module inherits and overrides the write data interface of the system module.
[0025] The present invention is further illustrated by a specific example below: When you want to add a freezing module for freezing the remaining electric energy in the electric energy meter system, first add the NameID corresponding to the freezing module in the enumeration type of the NameID table, for example, "FREEZE_APP", and add the NameID of the module data table corresponding to the freezing module in the enumeration type of the NameID table, for example, "FREEZE_HOUR_ATTRIBUTE", and add the message name that the freezing module will send in the enumeration type of the MessageID table, for example, the second message "SEC_ID_MSG" in the synchronization message.
[0026] When registering a frozen module, the CMODULE function is called in the constructor of this module. During the registration process, the frozen module and its module data table are registered in the module object array of the system module. At this time, the frozen module instance and its module data table are newly added to the module object array. The frozen module registers a total of five interfaces, namely data initialization interface, data reading interface, data writing interface, message dispatching interface and display interface. These interfaces inherit and override the interfaces of the corresponding system modules.
[0027] When the freezing module needs to send a second message, it sends the message message to the system module through the message dispatching interface, and obtains the name of the corresponding second message "SEC_ID_MSG" by searching the MessageID table. The content of the message refers to freezing the remaining electric energy and controlling the electric energy meter to stop working. Since the message is a synchronous message, the system module will traverse each business module in time after receiving the message message, that is, send the message message to each business module. As long as there is a code that responds to the message message in the corresponding business module, corresponding processing will be performed, for example, the display module and the control module, the display module and the control module execute the code that responds to the message.
[0028] After receiving the message, the control module executes the relevant code to control the power meter to shut down and no longer supply power. After receiving the message, the display module executes the relevant code. Since the display module needs to read the remaining power data in the module data table of the power module at this time, it sends a read data request message including the NameID of the module data table of the power module to the system module through its own read data interface. The system module finds the module data table of the power module in the module object array according to the NameID of the module data table in the read data request message, and then accesses the module data table of the power module to read the remaining power data in the module data table of the power module. Then, the system module sends the remaining power data read to the display module, and the display module calls its own display interface to display the remaining power on the display screen of the power meter.
[0029] Electric energy meter embodiment: This embodiment provides an electric energy meter. When performing business scheduling, the software system used by the electric energy meter uses an electric energy meter business scheduling method as introduced in the method embodiment. Since the introduction of the method is clear enough, it will not be repeated here.
[0030] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for dispatching electric energy meter services, characterized in that: When the business modules for realizing the specific functions of the electric energy meter are used for message transmission, the business module sending the message obtains the business name of the message sent by the corresponding business module when sending the message message through the MessageID table, and then sends the message message of the business name to the system module, and the system module sends the message message to other business modules, and then other business modules perform corresponding processing as needed; the MessageID table is used to store the business name of each business message of each business module; when the business modules exchange data, the business module obtains the module data table name of the business module that wants to exchange data through the NameID table, and then sends a data request message including the obtained module data table name to the system module, the system module finds the corresponding module data table according to the module data table name in the data request message, and then the system module executes the data processing logic corresponding to the data request message in the module data table; the NameID table is used to store the module data table name of the module data table of each business module, the module data table is used to store the data of the corresponding business module, and the data request message includes a read data request message and a write data request message.
2. The electric energy meter service dispatching method according to claim 1, characterized in that: The MessageID table also includes the name of the message sent by the system module. The system module obtains the name of the message required by the system module when sending a message message through the MessageID table, sends the message message to each business module, and then the business module performs corresponding processing.
3. The electric energy meter service dispatching method according to claim 2, characterized in that: The system module sends the message message to the corresponding service module. After receiving the message message, if there is a code corresponding to the message message in the service module, the service module performs corresponding processing.
4. The electric energy meter service dispatching method according to claim 1, characterized in that: The business module or system module sends the message message to the system module or business module through the message dispatch interface of this module; the business module sends the read data request message to the system module through the read data interface of this module, and the system module reads the data in the module data table through the read data interface of this module; the business module sends the write data request message to the system module through the write data interface of this module, and the system module writes data to the module data table through the write data interface of this module; the message dispatch interface, read data interface and write data interface of the business module respectively inherit and rewrite the message dispatch interface, read data interface and write data interface of the system module.
5. The electric energy meter service dispatching method according to claim 1, characterized in that: The message message includes a synchronous message message or an asynchronous message message. When the system module receives a synchronous message message, the system module promptly sends the synchronous message message to the business module. When the system module receives an asynchronous message message, the system module waits until the next round of message processing to send the asynchronous message message to the business module.
6. An electric energy meter, characterized in that: The software system of the electric energy meter includes a system module and various business modules for realizing specific functions of the electric energy meter. The system module includes a MessageID table for storing the business name of each business message of each business module and a NameID table for storing the module data table name of the module data table of each business module. The module data table is used to store data of the corresponding business module. When the business modules transmit messages to each other, the business module sending the message obtains the business name of the message sent by the corresponding business module when sending the message message through the MessageID table, and then sends the message message of the business name to the system module, and the system module sends the message message to other business modules, and then other business modules perform corresponding processing as needed. When the business modules interact with each other, the business module obtains the module data table name of the business module that wants to interact with data through the NameID table, and then sends a data request message including the obtained module data table name to the system module. The system module finds the corresponding module data table according to the module data table name in the data request message, and then the system module executes the data processing logic corresponding to the data request message in the module data table. The data request message includes a read data request message and a write data request message.
7. The electric energy meter according to claim 6, characterized in that: The MessageID table also includes the name of the message sent by the system module. The system module obtains the name of the message required by the system module when sending a message message through the MessageID table, sends the message message to each business module, and then the business module performs corresponding processing.
8. The electric energy meter according to claim 7, characterized in that: The system module sends the message message to the corresponding service module. After receiving the message message, if there is a code corresponding to the message message in the service module, the service module performs corresponding processing.
9. The electric energy meter according to claim 6, characterized in that: The business module or system module sends the message message to the system module or business module through the message dispatch interface of this module; the business module sends the read data request message to the system module through the read data interface of this module, and the system module reads the data in the module data table through the read data interface of this module; the business module sends the write data request message to the system module through the write data interface of this module, and the system module writes data to the module data table through the write data interface of this module; the message dispatch interface, read data interface and write data interface of the business module respectively inherit and rewrite the message dispatch interface, read data interface and write data interface of the system module.
10. The electric energy meter according to claim 6, characterized in that: The message message includes a synchronous message message or an asynchronous message message. When the system module receives a synchronous message message, the system module promptly sends the synchronous message message to the business module. When the system module receives an asynchronous message message, the system module waits until the next round of message processing to send the asynchronous message message to the business module.