A multi-mode data storage, configuration, reading and writing method based on ANSI C12.19

By generating data mapping relationships and designing unified data structure description files, the difficulties of data storage, configuration, and reading and writing in the ANSI C12.19 protocol are solved, data storage and conversion of electricity meters, concentrators, and relay equipment are realized, and the reading and writing of key-value pairs and relational databases are supported, which improves operational convenience and scalability.

CN120234327BActive Publication Date: 2025-09-23WILLFAR INFORMATION TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510703125.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-29
Publication Date
2025-09-23
Estimated Expiration
2045-05-29

AI Technical Summary

Technical Problem

Existing technologies cannot effectively implement data storage, configuration, and reading and writing of the ANSI C12.19 protocol, especially because the data types are diverse and poorly self-descriptive, resulting in unfriendly manual configuration and a mismatch between the transmission format and the storage format.

Method used

By generating a set of mapping relationships between transmitted data and stored data, designing a unified data structure description file that is independent of the database, and providing a standardized data read and write interface, it supports the read and write design of key-value pairs and relational databases, and realizes intelligent conversion of data formats.

Benefits of technology

It implements multi-mode data storage, configuration, and reading and writing based on the ANSI C12.19 protocol, with a simple process and convenient operation. It is suitable for electricity meters, concentrators, and relay equipment, supports dynamic configuration of different storage methods, and improves application development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120234327B_ABST
    Figure CN120234327B_ABST
Patent Text Reader

Abstract

The present invention is applicable to the technical field of the electric power industry and relates to a multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19, comprising: S10, converting transmission data and storage data, and generating a mapping relationship set between the transmission data structure and the storage data structure based on an attribute data type mapping table; S20, designing a set of unified data structure description files independent of the database, initializing the database, and importing the unified data structure description files into the database via an XML configuration import program; S30, standardizing a data read and write interface, and performing read and write design for key-value databases and relational databases. The present invention has a simple process and convenient operation, and implements multi-mode data storage, configuration, and reading and writing based on the ANSI C12.19 protocol, facilitating subsequent expansion and accelerating application development and delivery.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of the electric power industry, and in particular relates to a multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19. Background Art

[0002] The IEC62056 series of standards and the ANSI C12 series of standards cover the communication protocols for electricity metering equipment and meters. The IEC62056 standard defines the DLMS / COSEM protocol, with the goal of specifying a business-oriented interface object model standard for devices and systems, as well as a standard for accessing services for these objects. The ANSI C12 standard defines the PSEM (Protocol Specification for Electricity Metering) protocol to provide an interface between metering equipment and any other devices on a point-to-point communication medium.

[0003] The ANSI C12.19 protocol defines a total of 128 transmission tables, divided into 16 groups. However, the protocol only defines the transmission format of table data, not the storage format of the data. The transmission data format is more suitable for machine parsing than for manual configuration, modification, and reading. For example, time format data has BCD format, UINT8 format, and UINT32 format, which are extremely unfriendly for manual configuration. The data types and values ​​defined in the protocol are not self-descriptive structures and need to be parsed in conjunction with the ANSI C12.19 protocol. The data types and structures are diverse, and some data fields are interdependent, requiring correct handling of their initialization process and loading and parsing methods. The data storage format is not described in the protocol, and there are many options. It needs to be suitable for manual configuration and more convenient and fast to implement data reading and writing in different scenarios. It is urgent to determine the appropriate data storage and configuration method, implement the mapping relationship between transmission data format and storage data format data, and define standard data storage layer data reading and writing methods. Patent publication number CN109739858B provides a data classification storage method, device, and electronic device based on ANSI C12.19, including: obtaining a table to be stored; the table to be stored is a functional table defined by the ANSI C12.19 communication protocol; the table to be stored includes multiple data to be stored; identifying the data types of the multiple data to be stored in the table to be stored; and storing the multiple data to be stored in a storage space according to the data types. This patent only implements data storage and does not provide relevant technical solutions for configuration, reading, and writing.

[0004] Therefore, how to implement data storage, configuration, reading and writing of the ANSI C12.19 protocol is an urgent problem to be solved by those skilled in the art. Summary of the Invention

[0005] In view of the shortcomings of the existing technology, the purpose of the present invention is to provide a multi-mode data storage, configuration and reading and writing method based on ANSI C12.19 to solve the problem that the existing technology cannot realize data storage, configuration and reading and writing based on the ANSI C12.19 protocol.

[0006] In order to solve the above technical problems, the present invention adopts the following technical solutions:

[0007] The present invention provides a multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19, comprising the following steps:

[0008] S10, converting the transmission data and the storage data, and generating a mapping relationship set between the transmission data structure and the storage data structure according to the attribute data type mapping table;

[0009] S20, designing a set of unified data structure description files that are independent of the database, initializing the database, and importing the data of the unified data structure description files into the database through an XML configuration import program;

[0010] S30. Standardize data reading and writing interfaces to perform reading and writing design for key-value databases and relational databases.

[0011] Furthermore, the specific steps of converting the transmitted data and the stored data in step S10 are as follows:

[0012] S101, configuration parameter loading: read the data of table 00, the FCT table of the group where the current data table is located, and the data of the FCT+1 table. Some tables read the data of other specified data tables;

[0013] S102, generating a mapping relationship between the transmission data structure and the storage data structure: determining the attributes required in the transmission data structure, the length of the attributes, and the parsing / encoding method based on the configuration parameters read in step S101;

[0014] S103, automatic data conversion: after obtaining the mapping relationship between the transmission data structure and the storage structure, the data is converted based on this relationship.

[0015] Furthermore, the specific steps for generating a mapping relationship set between the transmission data structure and the storage data structure are as follows:

[0016] S111, identifying the transmission table ID to be loaded;

[0017] S112, load the configuration parameters related to this transmission table, read the data of table 00, the FCT table of the group where the current data table is located, and the data of the FCT+1 table, and read the data of other specified data tables in some tables;

[0018] S113. Determine the attribute list, attribute length, and attribute type, and convert the uncertain table structure defined in the protocol into a determined table structure;

[0019] S114: Generate a mapping relationship set between the transmission data structure and the storage data structure according to the attribute data type mapping table.

[0020] Furthermore, the attributes of the unified data structure description file in step S20 include table name, XML file name corresponding to the transmission table, whether it is an array, and attribute list, wherein the attribute list includes attribute name, attribute type, attribute length, and whether it is a primary key.

[0021] Furthermore, the specific process of database initialization is as follows:

[0022] S201. Unify the design of database structure description files that are unrelated to the actual database, and design the database structure according to the transmission table structure and attribute data type mapping table of the ANSI C12.19 protocol;

[0023] S202, using a unique database initialization program, shielding the implementation of the underlying database, importing the structure description file data into the database, initializing the database structure according to the description file, and automatically generating an XML configuration file that is unrelated to the database;

[0024] S203, fill in the XML configuration file, manually fill in the initialization configuration file according to the functions and actual needs of the metering device, concentrator or relay device;

[0025] S204, using a unique XML configuration import program to import the XML configuration file data into the database and initialize the database data;

[0026] S205, standard database reading and writing, after initialization, use the marked database reading and writing interface to perform reading and writing operations on the database data. The externally defined standard interface has nothing to do with the database.

[0027] Furthermore, the database includes a relational database and a key-value pair database.

[0028] Furthermore, step S30 supports reading and writing data according to table ID+row number+field, where the row number and field are optional.

[0029] Furthermore, the function of the table ID is to query / write the first row of data, which means that when only the table ID is entered, the default row number is 1, and specific data / success is returned; the function of the table ID+row number is to query / write the specified row of data, which means operating the entire row of data and returning specific data / success; the function of the table ID+field is to query / write the specified field in the first row, which means operating on a certain field data in the first row and returning specific data / success; the function of the table ID+row number+field is to query / write the specified field in the specified row, which means operating on the specified field in the specified row and returning specific data / success.

[0030] Furthermore, the specific process of reading and writing key-value data is as follows:

[0031] S301. Index to the starting position of the data by TableId and row number;

[0032] S302: If the entire row of data is being operated, the entire row is directly read; if a single field is being operated, the offset position and length of the field are first obtained;

[0033] S303, read data of a specified length from the offset position;

[0034] S304, converting the database data format into the transmission table data format according to the data mapping relationship;

[0035] S305, converting the transmission data into storage format data according to the data mapping relationship;

[0036] S306. Determine the key value based on TableId and row number, where key is the data primary key.

[0037] S307. If the field name is not specified, the entire row is written using the TableId and row number as the key. If a single field is operated, the offset position and length of the field are first obtained, and the TableId and row number are used as the key to overwrite the field area data.

[0038] S308. Return success / failure.

[0039] Furthermore, the specific process of reading and writing relational data is as follows:

[0040] S311. Assemble SQL statements based on TableId, row number, and field name.

[0041] S312, execute the assembled SQL to read data;

[0042] S313, converting the database data format into the transmission table data format according to the data mapping relationship;

[0043] S314, converting the transmission data into storage format data according to the data mapping relationship;

[0044] S315. Assemble SQL based on TableId, row number, and field name;

[0045] S316, execute the assembled SQL to write data;

[0046] S317. Return success / failure.

[0047] Compared with the prior art, the multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 provided by the present invention has at least the following beneficial effects:

[0048] The existing technology cannot simultaneously implement data storage, configuration, and reading and writing based on the ANSI C12.19 protocol. The present invention has a simple process and convenient operation, and is suitable for data storage and data conversion in electricity meters, concentrators, and relay devices using the ANSI C12.19 protocol. The ANSI C12.19 table structure is tailored according to the functions to be implemented, and its data storage method is dynamically configured: key-value data format storage and relational data format storage. The application layer and storage layer are decoupled, and data is intelligently converted by establishing bidirectional mapping rules. The storage layer is standardized, allowing the storage layer to use different storage methods. The application layer does not need to pay attention to the specific data storage method when reading and writing data, and it facilitates subsequent expansion and accelerates application development and delivery. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the scheme of the present invention, a brief introduction is given below to the figures required for use in the description of the embodiments. Obviously, the figures described below are some embodiments of the present invention. For ordinary technicians in this field, other figures can be obtained based on these figures without paying any creative work.

[0050] Figure 1 A flowchart of a multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 provided in an embodiment of the present invention;

[0051] Figure 2 A flow chart of the conversion between transmitted and stored data in a multi-mode data storage, configuration, and reading / writing method based on ANSI C12.19 provided in an embodiment of the present invention;

[0052] Figure 3 A flow chart for generating a mapping relationship between a transmission data structure and a storage structure for a multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 provided in an embodiment of the present invention;

[0053] Figure 4A flowchart of a database initialization method for storing, configuring, and reading and writing multiple data in accordance with ANSI C12.19 provided in an embodiment of the present invention;

[0054] Figure 5 A key-value pair data structure diagram of a multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 provided in an embodiment of the present invention;

[0055] Figure 6 A flowchart of a key-value pair data reading method for a multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 provided in an embodiment of the present invention;

[0056] Figure 7 A flowchart of a key-value pair data writing method for a multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 provided in an embodiment of the present invention;

[0057] Figure 8 A relational data structure diagram of a multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 provided in an embodiment of the present invention;

[0058] Figure 9 A flowchart of a relational data reading method for multi-mode data storage, configuration, and reading and writing based on ANSI C12.19 provided in an embodiment of the present invention;

[0059] Figure 10 The present invention provides a relational data writing and retrieval process based on ANSI C12.19 multi-mode data storage, configuration, and reading and writing methods. DETAILED DESCRIPTION

[0060] To facilitate understanding of the present invention, the present invention will be described more fully below with reference to the accompanying drawings. Preferred embodiments of the present invention are shown in the accompanying drawings. However, the present invention may be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and comprehensive understanding of the present disclosure.

[0061] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention.

[0062] An embodiment of the present invention provides a multi-mode data storage, configuration, and reading / writing method based on ANSI C12.19, which is applied to data storage and data conversion in electric meters, concentrators, and relay devices using the ANSI C12.19 protocol. The multi-mode data storage, configuration, and reading / writing method based on ANSI C12.19 includes the following steps:

[0063] S10. Convert transmission data and storage data, and generate a set of mapping relationships between transmission data structure and storage data structure according to the attribute data type mapping table; S20. Design a set of unified data structure description files that are independent of the database, initialize the database and import the unified data structure description files into the database through the XML configuration import program; S30. Standardize the data reading and writing interface, and perform reading and writing design of key-value databases and relational databases.

[0064] The present invention has a simple process and convenient operation, and realizes multi-mode data storage, configuration, and reading and writing based on the ANSI C12.19 protocol, which facilitates subsequent expansion and accelerates application development and delivery.

[0065] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.

[0066] The embodiment of the present invention provides a multi-mode data storage, configuration and reading and writing method based on ANSI C12.19, which is applied to the storage and data conversion of data in electric meters, concentrators and relay devices using the ANSI C12.19 protocol. The data described in the protocol is divided into two categories, one is configuration data with a small amount of data, and the other is metering data, event data, and log data with a large amount of data. For configuration data with a small amount of data, the data volume is small and initialization configuration is required, so the configuration is performed in XML format, making the configuration more user-friendly, and the data is stored in a key-value database, taking into account both reading and writing speed and efficiency, and is machine-friendly. For metering data, event data, and log data with a large amount of data, which are generated during operation and have a complex structure and need to support queries with multiple query conditions, taking into account reading and writing efficiency, an embedded small relational database is used to store the data. The correspondence between the data type and the storage type and the length correspondence in the ANSI C12.19 protocol are defined, so that the transmission format data and the storage format data can be converted to each other efficiently and quickly. Specifically, combined with Figures 1 to 10 In this embodiment, the multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 includes the following steps:

[0067] S10: Convert the transmission data and the storage data, and generate a mapping relationship set between the transmission data structure and the storage data structure according to the attribute data type mapping table.

[0068] Specifically, in this embodiment, Figure 1 As shown in the figure, the table data format described in ANSI C12.19 is not a fixed data format. It contains a large number of if / else judgment conditions to determine the table data format, and the length information of some data is determined by other configuration tables. The configuration table that generally determines the data table structure is table 00, as well as the first maximum limit table and the second actual limit table of the group to which the data table belongs. Some tables also depend on data tables in other groups. Therefore, the following process is required to convert between the transmission data structure and the storage data structure:

[0069] S101, configuration parameter loading, mainly reads the data of table 00, the FCT table of the group where the current data table is located (the first table of each group), and the data of FCT+1 table (the second table of each group). Some tables also need to read data from other specified data tables; for example, if data conversion is required for transmission table 18, the data of tables 00, 10, and 11 need to be read (the group where table 18 is located is group 1).

[0070] S102. Generate a mapping relationship between the transmission data structure and the storage structure. Based on the configuration parameters read in S101, determine the attributes required in the transmission data structure, the length of the attributes, and the parsing / encoding method. Since the format of the transmission data is determined by the protocol and has nothing to do with the database table format, to ensure that the database design is independent of the configuration and can cover all optional attributes, the database design adopts a full set design, and the attributes with dynamic length adopt the maximum supported length to ensure the static nature of the database structure.

[0071] S103: Automatic data conversion. After obtaining the mapping relationship between the transmission data structure and the storage structure, the data is converted based on this relationship.

[0072] Furthermore, in this embodiment, when generating the mapping relationship between the transmission data structure and the storage structure, it is necessary to process many data types defined in ANSI C12.19. The following Table 1 shows the correspondence between the data types in the protocol and the storage data types, i.e., the attribute data type mapping table, and performs data conversion according to the transmission data type:

[0073] Table 1

[0074]

[0075] Furthermore, in this embodiment, if Figure 3As shown, the Table data format described in ANSI C12.19 requires reading actual configuration information to convert uncertain if / else judgment conditions into a certain attribute list. The maximum length of some attributes is configured in the FCT table (the first table in each group) and the FCT+1 table (the second table in each group). The 00 table configuration also determines the data format of time, built-in type NI_FMAT1, and built-in type NI_FMAT2. The specific process is as follows:

[0076] S111 . Identify the transmission table ID to be loaded.

[0077] S112. Load the configuration parameters related to this transmission table, read the data of table 00, the FCT table of the group where the current data table is located (the first table of each group), and the data of FCT+1 table (the second table of each group). Some tables also need to read the data of other specified data tables.

[0078] S113. Determine the attribute list, attribute length, and attribute type, and convert the uncertain table structure defined in the protocol into a determined table structure.

[0079] S114. Generate a mapping relationship set between the transmission data structure and the storage data structure according to the attribute data type mapping table.

[0080] S20. Design a set of unified data structure description files that are independent of the database, initialize the database, and import the data of the unified data structure description files into the database through the XML configuration import program.

[0081] Specifically, in this embodiment, the database is mainly composed of structure and instance data, and the database structure description file determines the database structure; regardless of whether a key-value pair database or a relational database is used, a unified set of customized database structure description files is used, and the database structure initialization conversion program is used to initialize its structure according to the database actually used. The database structure description file is only related to the ANSI C12.19 protocol and has nothing to do with the specific database used. It is used to describe the XML configuration file name corresponding to each transmission table, the database field name, length and type, whether it is multi-line, and if there is an ARRAY sub-attribute in the transmission table structure, then a sub-table is designed for the ARRAY element. If there is a nested ARRAY element, then a sub-table of the sub-table is created, and so on. By defining the complete set of this database structure description file according to the ANSI C12.19 protocol, the structure of this database and the structure of the XML configuration file corresponding to each transmission table can be determined. The attributes to be described in the structure description file are shown in Table 2 below:

[0082] Table 2

[0083]

[0084] Furthermore, in this embodiment, if Figure 4 As shown in the figure, a unified database structure description file (regardless of database), database initialization mainly includes data structure initialization and data initialization. For small data volumes, XML format is used for configuration, making the configuration more user-friendly. The XML configuration import program is used to store data in the database, taking into account read and write speed and efficiency, and is machine-friendly. The database description file determines the database structure, while the XML configuration data determines the instance data. The database initialization process is as follows:

[0085] S201. Unify the design of database structure description files that are unrelated to the actual database, and design the database structure according to the transmission table structure and attribute data type mapping table of the ANSI C12.19 protocol.

[0086] S202. Use a unique database initialization program to shield the implementation of the underlying database, import the structure description file data into the database (supports relational databases and key-value databases), initialize the database structure according to the description file, and automatically generate an XML configuration file that is independent of the database.

[0087] S203, filling in the XML configuration file: manually filling in the initialized configuration file according to the functions and actual requirements of the metering device, concentrator or relay device.

[0088] S204. Use a unique XML configuration import program to import the XML configuration file data into the database (supports relational databases and key-value databases) and initialize the database data.

[0089] S205, standard database reading and writing, after initialization, use the marked database reading and writing interface to perform reading and writing operations on the database data. The externally defined standard interface has nothing to do with the database.

[0090] S30. Standardize data reading and writing interfaces to perform reading and writing design for key-value databases and relational databases.

[0091] Specifically, in this embodiment, the ANSI C12.19 protocol defines the transmission structure of protocol table data, which is used for data transmission in the ANSI C12.18, ANSI C12.21, and ANSI C12.22 protocols. It needs to support a complete data read and write process, while shielding the differences in the underlying data storage and providing a unified external data read and write process. Regardless of the database used by the storage layer to store data, a unified standard data read and write interface is provided to the outside world. Most tables have only one row and no nested structure. Data can be read and written by table ID (main type) + row number + field (subtype), where row number and field are optional. For other specific query requirements, the interface can be expanded by yourself. As shown in Table 3 below:

[0092] Table 3

[0093]

[0094] Furthermore, in this embodiment, combined with Figures 5 to 7 Key-value databases store data in a key:value format, where the key is the primary key and the value is the data value. Keys allow for rapid data read and write, making them more efficient than relational databases. Keys use the table name and row number, with the default row number being 1 for non-multi-row data. Row attribute data is used as the value, supporting queries by key or key + attribute name. When the database is initialized, all table information is stored in the key-value database to record the offset and length of table fields for subsequent indexing and data parsing. The key-value data read and write process is as follows:

[0095] S301. Index to the starting position of the data according to TableId and row number.

[0096] S302: If the operation is for an entire row of data, the entire row is directly read; if the operation is for a single field, the offset position and length of the field are first obtained.

[0097] S303: Read data of a specified length from the offset position.

[0098] S304: Convert the database data format into the transmission table data format according to the data mapping relationship.

[0099] S305: Convert the transmission data into storage format data according to the data mapping relationship.

[0100] S306. Determine the key value based on TableId and row number, where key is the data primary key.

[0101] S307. If the field name is not specified, the entire row is written using TableId and row number as the key. If a single field is operated, the offset position and length of the field are first obtained, and the field area data is overwritten using TableId and row number as the key.

[0102] S308. Return success / failure.

[0103] Furthermore, in this embodiment, combined with Figures 8 to 10 , the data of the relational database is stored in the form of tables. The table structure includes the table name and the table field set; the data is added, deleted, modified and checked through SQL statements. If the attribute is an ARRAY structure type, a subtable is created to store the ARRAY structure data. It is recommended to choose a lightweight embedded relational database here. When the database is initialized, the names and field information of all tables will be stored in another master table. Other tables will be automatically created by reading the table structure data in the master table, and the initialized data will be written according to the XML configuration information. Relational databases generally support SQL queries, and according to the standard interface definition, standard SQL is automatically assembled according to the query conditions. The relational data reading process is as follows:

[0104] S311. Assemble SQL according to TableId, row number, and field name.

[0105] S312: Execute the assembled SQL to read data.

[0106] S313. Convert the database data format into the transmission table data format according to the data mapping relationship.

[0107] S314: Convert the transmission data into storage format data according to the data mapping relationship.

[0108] S315. Assemble SQL based on TableId, row number, and field name.

[0109] S316: Execute the assembled SQL to write data.

[0110] S317. Return success / failure.

[0111] Example 1

[0112] The following is a design for Table04 in Group 0 of ANSI C12.19. Table04 contains array attributes and requires a sub-table structure.

[0113] The database structure description file format.xml, the content example is as follows:

[0114] <allparameter>

[0115] <param>

[0116] <paramname> RECORD04< / paramname>

[0117] <filepath> table04.xml< / filepath>

[0118] <ismulti> false< / ismulti>

[0119] <item>

[0120] <itemname> STANDARD_PENDING< / itemname>

[0121] <type> 5< / type>

[0122] <length> 255< / length>

[0123] < / item>

[0124] <item>

[0125] <itemname> MANUFACT_PENDING< / itemname>

[0126] <type> 5< / type>

[0127] <length> 255< / length>

[0128] < / item>

[0129] <item>

[0130] <itemname> LAST_ACTIVATION_DATE_TIME< / itemname>

[0131] <type> 2< / type>

[0132] <length> 10< / length>

[0133] < / item>

[0134] <item>

[0135] <itemname> NBR_PENDING_ACTIVATION< / itemname>

[0136] <type> 9< / type>

[0137] <length> 1< / length>

[0138] < / item>

[0139]

[0140] <param>

[0141] <paramname> RECORD04_01< / paramname>

[0142] <filepath> table04_01.xml< / filepath>

[0143] <ismulti> true< / ismulti>

[0144] <item>

[0145] <itemname> EVENT__EVENT_SELECTOR< / itemname>

[0146] <type> 5< / type>

[0147] <length> 1< / length>

[0148] < / item>

[0149] <item>

[0150] <itemname> EVENT__EVENT_STORAGE< / itemname>

[0151] <type> 5< / type>

[0152] <length> 5< / length>

[0153] < / item>

[0154] <item>

[0155] <itemname> TABLE_SELECTOR< / itemname>

[0156] <type> 5< / type>

[0157] <length> 2< / length>

[0158] < / item>

[0159]

[0160] < / allparameter>

[0161] Because of the existence of sub-tables, two XML configuration files will be generated. The contents of the table04.xml file are as follows:

[0162] <?xml version="1.0" standalone="no" encoding="gb2312" ?>

[0163] <allparameter>

[0164] <record04>

[0165] <chgtime> 1119841269< / chgtime>

[0166] <STANDARD_PENDING>00 00< / STANDARD_PENDING>

[0167] <MANUFACT_PENDING>00 01< / MANUFACT_PENDING>

[0168] <LAST_ACTIVATION_DATE_TIME>2411210947< / LAST_ACTIVATION_DATE_TIME>

[0169] <NBR_PENDING_ACTIVATION>1< / NBR_PENDING_ACTIVATION>

[0170]

[0171] < / allparameter>

[0172] The table04_01.xml sub-table file content example is as follows:

[0173] <?xml version="1.0" standalone="no" encoding="gb2312" ?>

[0174] <allparameter>

[0175] <RECORD04_01>

[0176] <itemno> 1< / itemno>

[0177] <EVENT__EVENT_SELECTOR>11< / EVENT__EVENT_SELECTOR>

[0178] <EVENT__EVENT_STORAGE>00 00 00 00 00< / EVENT__EVENT_STORAGE>

[0179] <TABLE_SELECTOR>00 0D< / TABLE_SELECTOR>

[0180] < / RECORD04_01>

[0181] <RECORD04_01>

[0182] <itemno> 2< / itemno>

[0183] <EVENT__EVENT_SELECTOR>12< / EVENT__EVENT_SELECTOR>

[0184] <EVENT__EVENT_STORAGE>00 00 00 00 00< / EVENT__EVENT_STORAGE>

[0185] <TABLE_SELECTOR>00 0E< / TABLE_SELECTOR>

[0186] < / RECORD04_01>

[0187] < / allparameter>

[0188] The multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 described in the above embodiment is compared with the existing technology, which is unable to simultaneously implement data storage, configuration, and reading and writing based on the ANSI C12.19 protocol. The present invention has a simple process and convenient operation, and is suitable for data storage and data conversion in electricity meters, concentrators, and relay devices using the ANSI C12.19 protocol. The ANSI C12.19 table structure is tailored according to the functions to be implemented, and its data storage method is dynamically configured: key-value data format storage, relational data format storage; the application layer and the storage layer are decoupled, and data is intelligently converted into data form by establishing bidirectional mapping rules. The storage layer is standardized so that the storage layer can use different storage methods. The application layer does not need to pay attention to the specific data storage method when reading and writing data, and it facilitates subsequent expansion and accelerates application development and delivery.

[0189] Obviously, the embodiments described above are only preferred embodiments of the present invention, rather than all embodiments. The preferred embodiments of the present invention are given in the accompanying drawings, but they do not limit the patent scope of the present invention. The present invention can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present invention more thorough and comprehensive. Although the present invention has been described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions described in the aforementioned specific embodiments, or to make equivalent replacements for some of the technical features therein. Any equivalent structure made using the contents of the present invention specification and drawings, directly or indirectly used in other related technical fields, is also within the scope of patent protection of the present invention.

Claims

1. A multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19, characterized in that: The following steps are involved: S10. Generate a mapping relationship set between a transmission data structure and a storage data structure according to an attribute data type mapping table, and convert the transmission data and the storage data. The attribute data type mapping table is designed for the correspondence between the data type in the protocol and the storage data type. The specific steps of converting the transmitted data into the stored data in S10 are as follows: S101, configuration parameter loading: read the data of table 00, the FCT table of the group where the current data table is located, and the data of the FCT+1 table. Some tables read the data of other specified data tables; S102, generating a mapping relationship between the transmission data structure and the storage data structure: Based on the configuration parameters read in S101, determine the attributes required in the transmission data structure, the length of the attributes, and the parsing / encoding method, and convert the uncertain table structure defined in the protocol into a determined table structure; based on the attribute data type mapping table, generate a mapping relationship set between the transmission data structure and the storage data structure; S103, automatic data conversion: after obtaining the mapping relationship between the transmission data structure and the storage structure, convert the data based on this relationship; S20, designing a set of unified data structure description files that are independent of the database, initializing the database, and importing the data of the unified data structure description files into the database through an XML configuration import program; S30. Standardize data reading and writing interfaces to perform reading and writing design for key-value databases and relational databases.

2. The multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 according to claim 1, characterized in that: The attributes of the unified data structure description file in S20 include table name, XML file name corresponding to the transmission table, whether it is an array, and attribute list, wherein the attribute list includes attribute name, attribute type, attribute length, and whether it is a primary key.

3. The multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 according to claim 1, characterized in that: The specific process of database initialization is as follows: S201. Unify the design of database structure description files that are unrelated to the actual database, and design the database structure according to the transmission table structure and attribute data type mapping table of the ANSI C12.19 protocol; S202, using a unique database initialization program, shielding the implementation of the underlying database, importing the structure description file data into the database, initializing the database structure according to the description file, and automatically generating an XML configuration file that is unrelated to the database; S203, fill in the XML configuration file, manually fill in the initialization configuration file according to the functions and actual needs of the metering device, concentrator or relay device; S204, using a unique XML configuration import program to import the XML configuration file data into the database and initialize the database data; S205, standard database reading and writing, after initialization, use the marked database reading and writing interface to perform reading and writing operations on the database data. The externally defined standard interface has nothing to do with the database.

4. The multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 according to claim 3, characterized in that: The database includes a relational database and a key-value pair database.

5. The multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 according to claim 1, characterized in that: The S30 supports reading and writing data according to table ID+row number+field, where the row number and field are optional.

6. The multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 according to claim 5, characterized in that: The function of table ID is to query / write the first row of data. When only the table ID is entered, the default row number is 1, and specific data is returned successfully. The function of table ID + row number is to query / write the data of a specified row, which means operating the entire row of data and returning specific data successfully. The function of table ID + field is to query / write the specified field in the first row, which means operating the data of a certain field in the first row and returning specific data successfully. The function of table ID + row number + field is to query / write the specified field in the specified row, which means operating the specified field in the specified row and returning specific data successfully.

7. The multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 according to claim 6, characterized in that: The specific process of reading and writing key-value data is as follows: S301. Index to the starting position of the data by TableId and row number; S302: If the entire row of data is being operated, the entire row is directly read; if a single field is being operated, the offset position and length of the field are first obtained; S303, read data of a specified length from the offset position; S304, converting the database data format into the transmission table data format according to the data mapping relationship; S305, converting the transmission data into storage format data according to the data mapping relationship; S306. Determine the key value based on TableId and row number, where key is the data primary key. S307. If the field name is not specified, the entire row is written using the TableId and row number as the key. If a single field is operated, the offset position and length of the field are first obtained, and the TableId and row number are used as the key to overwrite the field area data. S308. Return success / failure.

8. The multi-mode data storage, configuration, and reading and writing method based on ANSI C12.19 according to claim 7, characterized in that: The specific process of reading and writing relational data is as follows: S311. Assemble SQL statements based on TableId, row number, and field name. S312, execute the assembled SQL to read data; S313, converting the database data format into the transmission table data format according to the data mapping relationship; S314, converting the transmission data into storage format data according to the data mapping relationship; S315. Assemble SQL based on TableId, row number, and field name; S316, execute the assembled SQL to write data; S317. Return success / failure.

Citation Information

Patent Citations

  • Data classification and storage methods, devices and electronic devices based on ANSI C12.19

    CN109739858B

  • Data classified storage method and device based on ANSI C12.19 and electronic equipment

    CN109739858A

  • Method of importing data to database, electronic device, and storage medium

    US20240273113A1