Method for reading and writing electric energy meter parameter variable based on array identification object attribute
By establishing a parameter attribute table and using arrays to identify object attributes, the problems of large code footprint and poor security in the management of electricity meter parameters are solved. This enables flexible storage and secure management of parameters, thereby improving the management efficiency of electricity meters.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- QINGDAO DINGJUN ELECTRIC CO LTD
- Filing Date
- 2025-08-05
- Publication Date
- 2026-06-19
AI Technical Summary
Traditional electricity meter parameter management lacks a unified attribute description, resulting in poor dynamic scalability. When processing similar parameters, it occupies a large amount of code space, and modifications need to be made in multiple places, lacking security and flexibility.
By establishing a parameter attribute table, parameter attributes are managed uniformly. An array is used to identify object attributes, and a maximum index and matching type are set to achieve parameter security and flexible storage, and simplify the process of adding and deleting parameters.
It achieves parameter security and flexibility, reduces code footprint, simplifies parameter management, improves search and retrieval efficiency, and enhances storage flexibility and security.
Smart Images

Figure CN122240889A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electricity meters, and in particular to a method for reading and writing electricity meter parameters based on array-identified object attributes. Background Technology
[0002] Traditional electricity meter parameter management lacks unified attribute descriptions and suffers from poor dynamic scalability. Furthermore, due to the large number of parameters, the decentralized parameter definitions necessitate modifying different attributes of the same parameter in multiple places when problems arise. There are two setting schemes for field applications of parameters: one via ESAM, and the other via permissions + password. The corresponding message sending order and the plaintext order after ESAM decryption are inconsistent, leading to traditional parameter programming essentially using two separate code snippets. When dealing with similar parameters but with many values (such as 99 LCD screens or 254 public holidays), the processing of such parameters consumes a significant amount of code space, lacking a unified processing mechanism. Summary of the Invention
[0003] In view of this, the present invention provides a method for reading and writing energy meter parameters based on array-identified object attributes. By establishing a parameter attribute table, adding or deleting parameters only requires adding or deleting a row in the corresponding parameter attribute table to list all attributes of the parameter, thus completing the addition or deletion of the parameter. Parameter permission judgment, parameter length judgment, and parameter restriction conditions are all written into the corresponding parameter attribute table, making parameter settings more secure. By setting the maximum index and matching type, the problem of excessive code usage for similar parameters is solved. The storage scheme includes parameter length, parameter offset and starting position in the total parameter storage, whether multiple backups are needed, whether verification is calculated, and secondary restrictions on the length of corresponding variable parameters, allowing users to adjust parameter storage more flexibly. Each row in the parameter attribute table corresponds to all attributes of each parameter, making it easy to look up and retrieve. When a parameter has ESAM settings or not, only the parameter type in the parameter attribute table needs to be updated.
[0004] To achieve the above objectives, the present invention provides the following technical solution: A method for reading and writing energy meter parameters based on array-identified object attributes includes the following steps: S100. Summarize the parameters and establish a parameter attribute table; S200, Obtain the parameter attribute table of the parameters to be written; S300, Obtain write permission; S400. Determine whether the parameter data to be written comes from storage or memory; S500: Determine if the length of the parameter to be written meets the requirements; S600. Determine whether the data of the parameters to be written in the message meets the corresponding parameter setting requirements; S700: Decrypts and adjusts the format of the data; S800 performs data updates and storage; S900 Notify other modules that their parameters have been modified.
[0005] Preferably, in step S100, the parameter attribute table includes maximum index, matching type, length type, read permission, write permission, storage scheme, parameter type, parameter data source, read method, write method, restriction method, and notification method, with each row corresponding to all attributes of the target parameter.
[0006] Preferably, in step S100, the storage scheme uses a three-backup scheme, some parameters use verification restrictions, and other parameters use a second page mapping to a first page mechanism.
[0007] Preferably, step S200 includes: S210. Obtain the row number of the target parameter in the parameter attribute table that matches the first three bytes of the parameter to be written, and obtain all attributes of the row. S220. Determine whether the matching type of the row containing the target parameter is all match; If all match, determine whether the fourth byte of the parameter to be written is consistent with the fourth byte of the target parameter in the same row; if consistent, obtain all attributes of the target parameter. If there is a partial match, determine whether the fourth byte of the parameter to be written is greater than the maximum index: If the index is less than or equal to the maximum index, then obtain all attributes of the target parameter and record the index of the parameter to be written.
[0008] Preferably, in step S400, If the target parameter is sourced from memory, obtain the corresponding memory data and data length according to the memory type; If the target parameter source is storage and all matching types match, obtain the corresponding data and data length according to the storage scheme; In other cases, the corresponding data and data length are obtained according to the storage scheme and the index of the parameter to be written.
[0009] Preferably, in step S500, the length requirement of the parameter to be written includes: If the target parameter is of variable length, then the length of the parameter to be written meets the storage scheme requirements of the attribute table and is less than the length of the target parameter. If the target parameter has a fixed length, then the length of the parameter to be written is equal to the target parameter length.
[0010] Preferably, in step S700, depending on the type of the target parameter, it is sent to ESAM in plaintext + MAC format for decryption, or in ciphertext + MAC format for decryption, or decryption is not required and only the corresponding permission password is checked for correctness. All the target parameters after decryption are adjusted in the same format.
[0011] Preferably, in step S800, If the target parameter's data source is memory, update the corresponding memory data according to the memory type; If the data source for the target parameter is storage, and the obtained write / storage permission is valid: If the matching type is all matches, write according to the corresponding write method and storage scheme; If the matching type is partial matching, adjust the data and data length in the storage scheme according to the index of the parameter to be written.
[0012] As can be seen from the above technical solutions, the method for reading and writing energy meter parameters based on array-identified object attributes provided by this invention establishes a parameter attribute table. This allows for adding or deleting parameters simply by adding or deleting a row in the corresponding parameter attribute table, listing all attributes of the parameter. Parameter permission checks, parameter length checks, and parameter restrictions are all written into the corresponding parameter attribute table, making parameter settings more secure. By setting a maximum index and matching type, the problem of excessive code usage for similar parameters is solved. The storage scheme includes parameter length, parameter offset and starting position in the total parameter storage, whether multiple backups are needed, whether verification is calculated, and secondary restrictions on the length of corresponding variable parameters, allowing users to adjust parameter storage more flexibly. Each row in the parameter attribute table corresponds to all attributes of each parameter, facilitating searching and retrieval. Whether a parameter has ESAM settings or not, only the parameter type in the parameter attribute table needs to be updated. Attached Figure Description
[0013] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0014] Figure 1This is a flowchart illustrating a method for reading and writing energy meter parameters based on array-identified object attributes, according to an exemplary embodiment. Figure 2 This is a schematic diagram illustrating, according to an exemplary embodiment, the read / write logic of an energy meter parameter based on an array-identified object attribute. Detailed Implementation
[0015] This invention discloses a method for reading and writing energy meter parameters based on array-identified object attributes. By establishing a parameter attribute table, adding or deleting parameters only requires adding or deleting a row in the corresponding parameter attribute table, listing all attributes of the parameter, thus completing the addition or deletion of the parameter. Parameter permission judgment, parameter length judgment, and parameter restriction conditions are all written into the corresponding parameter attribute table, making parameter settings more secure. By setting the maximum index and matching type, the problem of excessive code usage for similar parameters is solved. The storage scheme includes parameter length, parameter offset and starting position in the total parameter storage, whether multiple backups are needed, whether verification is calculated, and secondary restrictions on the length of corresponding variable parameters, allowing users to adjust parameter storage more flexibly. Each row in the parameter attribute table corresponds to all attributes of each parameter, making it easy to look up and retrieve. Whether the parameter has ESAM settings or not, only the parameter type in the parameter attribute table needs to be updated.
[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0017] This disclosure provides an exemplary embodiment of a method for reading and writing electricity meter parameters based on array-identified object attributes, such as... Figure 1 As shown, Figure 1 This is a flowchart illustrating a method for reading and writing energy meter parameters based on array-identified object attributes, according to an exemplary embodiment. Figure 2 This is a schematic diagram illustrating the read / write logic of energy meter parameters based on array-identified object attributes, according to an exemplary embodiment. The following is in conjunction with... Figure 1 and Figure 2 To explain.
[0018] The specific embodiments described below are intended to help those skilled in the art understand this embodiment, but this embodiment is not limited to the specific embodiments described below.
[0019] Reference Figure 1This disclosure provides an exemplary embodiment of a method for reading and writing energy meter parameters based on array-identified object attributes. The method includes the following steps: S100. Summarize the parameters and establish a parameter attribute table; S200, Obtain the parameter attribute table of the parameters to be written; S300, Obtain write permission; S400: Determine whether the parameter data to be written comes from storage or memory; S500: Determine if the length of the parameter to be written meets the requirements; S600: Determine whether the data of the parameters to be written in the message meets the corresponding parameter setting requirements; S700: Decrypts and adjusts the format of the data; S800 performs data updates and storage; S900 Notify other modules that their parameters have been modified.
[0020] For example, refer to Figure 1 Step S100: Summarize the parameters and establish a parameter attribute table. The parameter attribute table includes maximum index, matching type, length type, read permission, write permission, storage scheme, parameter type, parameter data source, read method, write method, restriction method, and notification method. Each row corresponds to all attributes of the target parameter.
[0021] For example, the parameter attribute table contains the following elements: Maximum Index and Matching Type: Matching types are divided into full match and partial match. For full match, the maximum index is fixed at 0. For partial match, the maximum index is the number of parameters of this parameter type.
[0022] Length type: It is divided into fixed length and variable length. When the length is variable, the parameter setting to be written is considered to be valid if the length is less than the maximum length of the target parameter.
[0023] Read, write, and store permissions: Read: This target parameter can be read, but some password parameters cannot be read and can only be set. Write: This target parameter can be written to and modified, but some target parameters cannot be written to, such as rated voltage and rated current. Store: This target parameter needs to be written to storage after being written; some target parameters, such as time parameters, can be read and written but do not need to be stored.
[0024] Storage Scheme: The storage scheme for the corresponding parameters can use a three-backup approach, with some parameters employing verification restrictions and others using a page-to-page mapping mechanism. This document does not restrict the specific parameter storage scheme; it simply treats them as attributes, requiring the use of appropriate access functions for subsequent read and write operations.
[0025] Parameter type: indicates the type of target parameter. Different types of parameters have different decryption methods.
[0026] Parameter data sources are divided into memory and storage. Memory data can be further categorized into: date, time, date and time, and signal strength. If the target parameter's data source is storage, then the corresponding target parameter is read according to the appropriate storage scheme, and the data is returned.
[0027] Reading methods include, but are not limited to, reading 1 byte, reading 2 bytes, reading 3 bytes, reading and then reversing the data, reading and then converting to BCD and then reversing the data, reading the time zone table, reading the time period table, and reading the location information. The reading methods correspond to the writing methods.
[0028] Write methods include, but are not limited to, writing 1 byte, writing 2 bytes, writing 3 bytes, writing ASCII code and flipping it, writing BCD and flipping it, writing location information, writing time zone table, and writing time period table. Read methods correspond to write methods.
[0029] Restriction methods: These are primarily used to determine the legality and validity of parameters to be written. For example, when setting the demand cycle, it must be a multiple of 5. Each target parameter corresponds to a restriction method to determine the legality and validity of each target parameter.
[0030] Notification methods: These are primarily used to notify other modules that use a target parameter after its setting has been modified, ensuring timely updates to the target parameter. Each target parameter has its own corresponding notification method, facilitating the notification of updates to other modules.
[0031] Step S200, obtaining the parameter attribute table of the parameters to be written, specifically includes: S210. Obtain the row number of the target parameter in the parameter attribute table that matches the first three bytes of the parameter to be written, and obtain all attributes of the row. S220. Determine whether the matching type of the row containing the target parameter is a full match; If all match, check if the fourth byte of the parameter to be written is the same as the fourth byte of the target parameter in the same row; if they match, retrieve all attributes of the target parameter. If there is a partial match, check if the fourth byte of the parameter to be written is greater than the maximum index: If the index is less than or equal to the maximum index, then retrieve all attributes of the target parameter and record the index of the parameter to be written.
[0032] For example: Check if the first 3 bytes of the parameter to be written match the first 3 bytes of the target parameter in the parameter attribute table. If they match, find the corresponding row in the parameter attribute table and check if the matching type of the target parameter in this row is a complete match.
[0033] If the result is a complete match, check if the fourth byte of the parameter to be written is consistent with the fourth byte of the target parameter in the parameter attribute table. If they are inconsistent, return an error indicating that there is no corresponding target parameter. If they are consistent, then this line is the line containing the parameter to be written, and retrieve all attributes of the target parameter in this line.
[0034] If the result is a partial match, check if the fourth byte of the parameter to be written is greater than the maximum index. If it is greater than the maximum index, return an error indicating that there is no corresponding target parameter. If it is less than or equal to the maximum index, then this line is the line containing the parameter to be written. Obtain all attributes of the target parameter in this line and record the index of the parameter to be written.
[0035] Step S300, obtaining write permissions, specifically includes: based on the obtained read / write permissions, determining whether the permissions allow writing. If writing is allowed, proceed to the next step. If writing is not allowed, return an error.
[0036] In some specific embodiments, it may be possible to first determine whether the permission is readable, and then determine whether it is writable.
[0037] Step S400: Determine whether the parameter data to be written originates from storage or memory. If the target parameter source is memory, obtain the corresponding memory data and data length according to the memory type; If the target parameter source is storage and all matching types match, obtain the corresponding data and data length according to the storage scheme; In other cases, the corresponding data and data length are obtained based on the storage scheme and the index of the parameter to be written.
[0038] In step S500, determining whether the length of the parameter to be written meets the requirements, the length requirements for the parameter to be written include: If the target parameter's length type is variable length, then the length of the parameter to be written must meet the storage scheme requirements in the attribute table and be less than the target parameter's length. If the target parameter has a fixed length, then the length of the parameter to be written is equal to the target parameter length.
[0039] S600: Determine whether the data of the parameters to be written in the message meets the corresponding parameter setting requirements. The determination is made according to the aforementioned restriction method. If it meets the requirements, proceed to the next step. If it does not meet the requirements, return failure.
[0040] In step S700, depending on the target parameter type, it is sent to ESAM in plaintext + MAC format for decryption, or in ciphertext + MAC format for decryption, or no decryption is required and only the corresponding permission password is checked for correctness. All decrypted target parameters are adjusted in the same format.
[0041] For example, the parameter types mentioned above represent the following: If it is a type 1 parameter, the message is sent to ESAM in plaintext + MAC format for decryption; if it is a type 2 parameter, the message is sent to ESAM in ciphertext + MAC format for decryption; if it is a type 3 parameter, decryption is not required, but it is necessary to check whether the corresponding authorization password is correct. The decrypted type 1 and type 2 parameters are then formatted according to the type 3 parameter format.
[0042] Step S800: Data update and storage are underway. If the target parameter's data source is memory, update the corresponding memory data according to the memory type; If the target parameter's data source is storage, and the obtained write / storage permissions are valid: If the matching type is all matches, write according to the corresponding write method and storage scheme; If the matching type is partial matching, write the corresponding data and data length according to the index of the parameter to be written; If the obtained write permission is not allowed, then no write operation will be performed.
[0043] Step S900: Notify other modules that the parameter has been modified. According to the aforementioned notification method, notify the relevant modules that the parameter has been changed. Other modules that use this parameter should update the parameter data as needed.
[0044] In this embodiment, by establishing a parameter attribute table, adding or deleting parameters only requires adding or deleting a row in the corresponding parameter attribute table to list all attributes of the parameter. Parameter permission checks, parameter length checks, and parameter restrictions are all written into the corresponding parameter attribute table, making parameter settings more secure. By setting a maximum index and matching type, the problem of excessive code usage for similar parameters is solved. The storage scheme includes parameter length, parameter offset and starting position in the total parameter storage, whether multiple backups are needed, whether verification is calculated, and secondary restrictions on the length of corresponding variable parameters, allowing users to adjust parameter storage more flexibly. Each row in the parameter attribute table corresponds to all attributes of each parameter, making it easy to search and retrieve. Whether a parameter has ESAM settings or not, only the parameter type in the parameter attribute table needs to be updated.
[0045] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those 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 invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for reading and writing energy meter parameters based on array-identified object attributes, characterized in that, Includes the following steps: S100. Summarize the parameters and establish a parameter attribute table; S200, Obtain the parameter attribute table of the parameters to be written; S300, Obtain write permission; S400. Determine whether the parameter data to be written comes from storage or memory; S500: Determine if the length of the parameter to be written meets the requirements; S600. Determine whether the data of the parameters to be written in the message meets the corresponding parameter setting requirements; S700: Decrypts and adjusts the format of the data; S800 performs data updates and storage; S900 Notify other modules that their parameters have been modified.
2. The method for reading and writing energy meter parameters based on array identifier object attributes according to claim 1, characterized in that, In step S100, the parameter attribute table includes maximum index, matching type, length type, read permission, write permission, storage scheme, parameter type, parameter data source, read method, write method, restriction method, and notification method. Each row of the parameter attribute table corresponds to all attributes of the target parameter.
3. The method for reading and writing energy meter parameters based on array identifier object attributes according to claim 2, characterized in that, In step S100, the storage scheme uses a three-backup scheme, some parameters use verification restrictions, and other parameters use a second page mapping to a first page mechanism.
4. The method for reading and writing energy meter parameters based on array identifier object attributes according to claim 3, characterized in that, Step S200 includes: S210. Obtain the row number of the target parameter in the parameter attribute table that matches the first three bytes of the parameter to be written, and obtain all attributes of the row. S220. Determine whether the matching type of the row containing the target parameter is all match; If all match, determine whether the fourth byte of the parameter to be written is consistent with the fourth byte of the target parameter in the same row; if consistent, obtain all attributes of the target parameter. If there is a partial match, determine whether the fourth byte of the parameter to be written is greater than the maximum index: If the index is less than or equal to the maximum index, then obtain all attributes of the target parameter and record the index of the parameter to be written.
5. The method for reading and writing energy meter parameters based on array identifier object attributes according to claim 3, characterized in that, In step S400 If the target parameter is sourced from memory, obtain the corresponding memory data and data length according to the memory type; If the target parameter source is storage and all matching types match, obtain the corresponding data and data length according to the storage scheme; In other cases, the corresponding data and data length are obtained according to the storage scheme and the index of the parameter to be written.
6. The method for reading and writing energy meter parameters based on array identifier object attributes according to claim 3, characterized in that, In step S500, the length requirement of the parameter to be written includes: If the target parameter is of variable length, then the length of the parameter to be written meets the storage scheme requirements of the attribute table and is less than the length of the target parameter. If the target parameter has a fixed length, then the length of the parameter to be written is equal to the target parameter length.
7. The method for reading and writing energy meter parameters based on array identifier object attributes according to claim 3, characterized in that, In step S700, depending on the target parameter type, the target parameter is sent to ESAM in plaintext + MAC format for decryption, or in ciphertext + MAC format for decryption, or no decryption is required and only the corresponding permission password is checked. All the target parameters after decryption are adjusted in the same format.
8. The method for reading and writing energy meter parameters based on array identifier object attributes according to claim 7, characterized in that, In step S800 If the target parameter's data source is memory, update the corresponding memory data according to the memory type; If the data source for the target parameter is storage, and the obtained write / storage permission is valid: If the matching type is all matches, write according to the corresponding write method and storage scheme; If the matching type is partial matching, adjust the data and data length in the storage scheme according to the index of the parameter to be written.