ANSI C12.19-based multimode data storage, configuration and read-write method
By generating a data mapping relationship set and designing a unified data structure description file, the data storage, configuration and reading and writing problems in the ANSI C12.19 protocol are solved, and convenient storage and conversion of data in the meter, concentrator and relay equipment is realized, and dynamic configuration and standardized reading and writing of various storage methods are supported.
Patent Information
- Application Number
- CN202510703125.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2045-05-29
AI Technical Summary
The prior art cannot effectively realize the data storage, configuration and reading and writing of the ANSI C12.19 protocol, especially the poor self-descriptiveness of the data types and structures, resulting in unfriendly manual configuration and it is difficult to quickly realize data reading and writing in different scenarios.
By generating a mapping relationship set between transmitted data and stored data, a unified data structure description file that is independent of the database is designed, and a standardized data read and write interface is provided to support the reading and writing design of key-value pairs and relational databases.
It realizes multi-way data storage, configuration and reading and writing based on the ANSI C12.19 protocol. The process is simple and the operation is convenient. It is suitable for meters, concentrators and relay devices. It supports dynamic configuration of different storage methods. The application layer is decoupled from the storage layer, which is convenient for expansion and rapid development.
Smart Images

Figure CN120234327A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of the power industry, and particularly 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 of electricity metering devices and electric meters. The IEC62056 standard defines the DLMS / COSEM protocol, aiming to specify a standard for an interface object model for the business domain for devices and systems, as well as a standard for services to access these objects; the ANSI C12 standard defines the PSEM (Power System Electric Metering Protocol Specification) protocol to provide an interface between metering devices and devices on any other point-to-point communication medium.
[0003] In the ANSI C12.19 protocol, a total of 128 transmission tables are defined and divided into 16 groups. However, the protocol only defines the transmission format of table data rather than the storage format of data. The transmission data format is more suitable for machine parsing, but not for manual configuration, modification, and reading. For example, data in time format has BCD format, UINT8 format, and UINT32 format, which is extremely unfriendly for manual configuration; the data types and values defined in the protocol are not self-descriptive structures, and the data needs to be parsed in combination with the ANSI C12.19 protocol. The data types and structures are diverse and some data fields are interdependent, and the initialization process and loading and parsing methods need to be correctly processed; the data storage format is not described in the protocol, and there are various choices, which need to be suitable for manual configuration and also need to more conveniently and quickly implement data reading and writing in different scenarios; it is urgent to determine a suitable data storage and configuration method, and it is also necessary to implement the mapping relationship between the transmission data format and the storage data format, and define a standard data reading and writing method for the data storage layer. The patent with the 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 function table defined by the ANSI C12.19 communication specification; the table to be stored includes a plurality of data to be stored; identifying the data types of the plurality of data to be stored in the table to be stored; and storing the plurality of data to be stored in a storage space according to the data types. This patent only realizes data storage and does not give relevant technical solutions for how to configure and read and write.
[0004] Therefore, how to implement the data storage, configuration, and 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] Aiming at the deficiencies of the prior art, the purpose of the present invention is to provide a multi-mode data storage, configuration, reading and writing method based on ANSI C12.19 to solve the problem that data storage, configuration, reading and writing based on the ANSI C12.19 protocol cannot be realized in the prior art.
[0006] 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, reading and writing method based on ANSI C12.19, including the following steps:
[0008] S10. Perform the conversion between transmission data and 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;
[0009] S20. Design a unified data structure description file independent of the database, initialize the database, and import the data into the database through the XML configuration import program of the unified data structure description file;
[0010] S30. Standardize the data reading and writing interface, and perform the reading and writing design of the key-value pair database and the reading and writing design of the relational database.
[0011] Further, the specific steps of the conversion between transmission data and storage data in step S10 are as follows:
[0012] S101. Configuration parameter loading: Read the data of Table 00, the FCT table and the FCT+1 table of the current data table group, and read the data of specified other data tables for some tables;
[0013] S102. Generation of the mapping relationship between the transmission data structure and the storage data structure: Determine the attributes, lengths of the attributes, and parsing / encoding methods required in the transmission data structure according to 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, perform mutual conversion of the data according to this relationship.
[0015] Further, the specific steps of generating the mapping relationship set between the transmission data structure and the storage data structure are as follows:
[0016] S111. Identify 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 and the FCT+1 table of the current data table group, and read the data of specified other data tables for some tables;
[0018] S113. Determine the attribute list, attribute length, and attribute type, and convert the undefined table structure defined in the protocol into a defined table structure;
[0019] S114. Generate a set of mapping relationships between the transmission data structure and the storage data structure according to the attribute data type mapping table.
[0020] Further, the attributes of the unified data structure description file in step S20 include the table name, the XML file name of the corresponding transmission table, whether it is an array, and the attribute list, where the attribute list includes the attribute name, attribute type, attribute length, and whether it is the primary key.
[0021] Further, the specific process of database initialization is as follows:
[0022] S201. Unify the design of the database structure description file independent of the actual database, and design the database structure according to the transmission table structure of the ANSI C12.19 protocol and the attribute data type mapping table;
[0023] S202. Use a specific database initialization program to shield the implementation of the underlying database, import the structure description file data into the database, initialize the database structure according to the description file, and automatically generate an XML configuration file independent of the database;
[0024] S203. Fill in the XML configuration file, and manually fill in the initialized configuration file according to the functions and actual requirements of the metering device, concentrator, or relay device;
[0025] S204. Use a specific 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 interfaces to perform reading and writing operations on the database data, and the externally defined standard interfaces are independent of the database.
[0027] Further, the database includes a relational database and a key-value pair database.
[0028] Further, in step S30, it supports reading and writing data by table ID + row number + field, where the row number and field are optional.
[0029] Further, the function of the table ID is to query / write the data in the first row. When only the table ID is input, 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 data in the specified row, indicating that the entire row of data is operated on, and specific data / success is returned; the function of the table ID + field is to query / write the specified field in the first row, indicating that the data of a certain field in the first row is operated on, and specific data / success is returned; the function of the table ID + row number + field is to query / write the specified field in the specified row, indicating that the specified field in the specified row is operated on, and specific data / success is returned.
[0030] Further, the specific process of reading and writing key-value pair data is as follows:
[0031] S301. Index to the starting position of the data according to the TableId and row number;
[0032] S302. If operating on the entire row of data, directly read the entire row. If operating on a single field, first obtain the offset position and length of the field;
[0033] S303. Read the data of the specified length from the offset position;
[0034] S304. Convert the database data format to the transmission table data format according to the data mapping relationship;
[0035] S305. Convert the transmitted data to the storage format data according to the data mapping relationship;
[0036] S306. Determine the key value according to the TableId and row number. The key is the data primary key;
[0037] S307. If the field name is not specified, write the entire row with the TableId and row number as the key. If operating on a single field, first obtain the offset position and length of the field, and overwrite and write the data in the field area with the TableId and row number as the key;
[0038] S308. Return success / failure.
[0039] Further, the specific process of reading and writing relational data is as follows:
[0040] S311. Assemble the SQL according to the TableId, row number, and field name;
[0041] S312. Execute the assembled SQL to read the data;
[0042] S313. Convert the database data format to the transmission table data format according to the data mapping relationship;
[0043] S314. Convert the transmitted data to the 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 / writing method based on ANSI C12.19 provided by the present invention has at least the following beneficial effects:
[0048] In the prior art, it is impossible to simultaneously implement data storage, configuration, and reading / writing based on the ANSI C12.19 protocol. The process of the present invention is simple and the operation is convenient. It is applicable to the data storage and data conversion in electric meters, concentrators, and relay devices using the ANSI C12.19 protocol. The ANSI C12.19 table structure is trimmed according to the functions to be realized, and its data storage method is dynamically configured: storing in key - value pair data format and relational data format; the decoupling design between the application layer and the storage layer enables the intelligent conversion of data forms by establishing two - way mapping rules, standardizes the storage layer, enables the storage layer to use different storage methods, and the application layer does not need to care about the specific data storage method when reading and writing data, which is convenient for subsequent expansion and speeds up the development and delivery of applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the solution of the present invention, the following will briefly introduce the drawings required in the description of the embodiments. Obviously, the following - described drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0050] Figure 1 It is a flowchart of a multi - mode data storage, configuration, and reading / writing method based on ANSI C12.19 provided by an embodiment of the present invention;
[0051] Figure 2 It is a flowchart of the conversion between transmission data and storage data of a multi - mode data storage, configuration, and reading / writing method based on ANSI C12.19 provided by an embodiment of the present invention;
[0052] Figure 3 It is a flowchart of generating the mapping relationship between the transmission data structure and the storage structure of a multi - mode data storage, configuration, and reading / writing method based on ANSI C12.19 provided by an embodiment of the present invention;
[0053] Figure 4A database initialization flowchart for a multi-mode data storage, configuration, and read / write method based on ANSI C12.19 provided by an embodiment of the present invention;
[0054] Figure 5 A key-value pair data structure diagram for a multi-mode data storage, configuration, and read / write method based on ANSI C12.19 provided by an embodiment of the present invention;
[0055] Figure 6 A key-value pair data reading flowchart for a multi-mode data storage, configuration, and read / write method based on ANSI C12.19 provided by an embodiment of the present invention;
[0056] Figure 7 A key-value pair data writing flowchart for a multi-mode data storage, configuration, and read / write method based on ANSI C12.19 provided by an embodiment of the present invention;
[0057] Figure 8 A relational data structure diagram for a multi-mode data storage, configuration, and read / write method based on ANSI C12.19 provided by an embodiment of the present invention;
[0058] Figure 9 A relational data reading flowchart for a multi-mode data storage, configuration, and read / write method based on ANSI C12.19 provided by an embodiment of the present invention;
[0059] Figure 10 A relational data writing flowchart for a multi-mode data storage, configuration, and read / write method based on ANSI C12.19 provided by an embodiment of the present invention. Detailed implementation manners
[0060] To facilitate the understanding of the present invention, the present invention will be described more comprehensively below with reference to the relevant drawings. The preferred embodiments of the present invention are shown in the drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, these embodiments are provided to make the understanding of the disclosure of the present invention more thorough and comprehensive.
[0061] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present invention belongs. The terms used in the description of the present invention herein 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, reading and writing method based on ANSI C12.19, which is applied to the data storage and data conversion in electric meters, concentrators and relay devices using the ANSI C12.19 protocol. The multi-mode data storage, configuration, reading and writing method based on ANSI C12.19 includes the following steps:
[0063] S10. Perform the conversion between transmission data and storage data, and generate a mapping relationship set of the transmission data structure and the storage data structure according to the attribute data type mapping table; S20. Design a unified data structure description file independent of the database, initialize the database, and import the data into the database through the XML configuration import program of the unified data structure description file; S30. Standardize the data reading and writing interface, and perform the reading and writing design of the key-value pair database and the reading and writing design of the relational database.
[0064] The process of the present invention is simple and convenient to operate, realizes multi-mode data storage, configuration, reading and writing based on the ANSI C12.19 protocol, is convenient for subsequent expansion, and speeds up the development and delivery of applications.
[0065] In order to enable those skilled in the art to better understand the solution 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] An embodiment of the present invention provides a multi-mode data storage, configuration, reading and writing method based on ANSI C12.19, which is applied to the data storage and data conversion 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 category is small-volume configuration data, and the other category is large-volume measurement data, event data, and log data. For the small-volume configuration data, since the data volume is small and initialization configuration is required, the XML format is used for configuration to make the configuration more user-friendly, and the data is stored in a key-value pair database to balance the reading and writing speed and efficiency and be machine-friendly. For the measurement data, event data, and log data with a large data volume, which are generated during operation, because their structures are relatively complex and multi-query condition queries need to be supported, and the reading and writing efficiency is balanced, an embedded small relational database is used to store the data. Define the correspondence relationship between the data types and storage types in the ANSI C12.19 protocol, and the length correspondence relationship, so that the transmission format data and the storage format data can be efficiently and quickly converted into each other. Specifically, combined with Figures 1 to 10 In this embodiment, the multi-mode data storage, configuration, reading and writing method based on ANSI C12.19 includes the following steps:
[0067] 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.
[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. There are a large number of if / else judgment conditions to determine the data format of the table, and the length information of some data is determined by other configuration tables. Generally, the configuration table that 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 where the data table is located. Some tables also depend on the data tables of other groups. Therefore, the following process needs to be executed to convert 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 FCT+1 table (the second table of no group). Some tables also need to read the data of other specified data tables; for example, if data conversion is required for transmission table 18: the data of table 00, table 10, and table 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. According to 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. Because the format of the transmission data is determined by the protocol and has nothing to do with the database table format, in order to ensure that the database design is independent of the configuration and can cover all optional attributes, the database is designed using a full set design, and the attributes with dynamic length use the maximum supported length to ensure the static nature of the database structure.
[0071] S103, automatically converting data, after obtaining the mapping relationship between the transmission data structure and the storage structure, converting the data based on this relationship.
[0072] Further, in this embodiment, when the mapping relationship between the transmission data structure and the storage structure is generated, it is necessary to process many data types defined in ANSI C12.19. The following Table 1 is a design of the correspondence between the data type in the protocol and the storage data type, that is, the attribute data type mapping table, and data conversion is performed according to the transmission data type:
[0073] Table 1
[0074] Further, in this embodiment, if Figure 3As shown in the figure, for the Table data format described in ANSI C12.19, it is necessary to read the actual configuration information, convert the uncertain if / else judgment conditions into a definite list of attributes, and configure the maximum lengths of some attributes in the FCT table (the first table in each group) and the FCT+1 table (the second table in each group of tables). Additionally, the 00 table configuration determines the data formats of time, the built-in type NI_FMAT1, and the built-in type NI_FMAT2. The specific process is as follows:
[0075] S111. Identify the ID of the transmission table to be loaded.
[0076] S112. Load the configuration parameters related to this transmission table, read the data of Table 00, the data of the FCT table (the first table in each group) of the current data table group, and the data of the FCT+1 table (the second table in each group). For some tables, it is also necessary to read the data of other specified data tables.
[0077] S113. Determine the list of attributes, attribute lengths, and attribute types, and convert the uncertain table structure defined in the protocol into a definite table structure.
[0078] S114. Generate a set of mapping relationships between the transmission data structure and the storage data structure based on the attribute data type mapping table.
[0079] S20. Design a unified data structure description file independent of the database, initialize the database, and import the data into the database through the XML configuration import program of the unified data structure description file.
[0080] Specifically, in this embodiment, the database mainly consists of a structure and instance data. The database structure description file determines the database structure. Whether using a key-value pair database or a relational database, a unified set of custom database structure description files is used. Through the database structure initialization conversion program, the structure is initialized according to the actual database used. This 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. 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 that need to be described in the structure description file are shown in Table 2 below:
[0081] Table 2
[0082] Furthermore, in this embodiment, asFigure 4 As shown in Figure 4 , there is a unified database structure description file (regardless of the database). Database initialization mainly includes the initialization of data structure and data. For the configuration data with a small amount of data, due to the small data volume, the XML format is used for configuration, making the configuration more user-friendly. And the XML configuration import program is used to store the data in the database, taking into account the reading and writing speed and efficiency, and being 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:
[0083] S201. Design a database structure description file that is independent of the actual database. According to the transmission table structure and attribute data type mapping table of the ANSI C12.19 protocol, design the database structure.
[0084] S202. Use a unique database initialization program to shield the implementation of the underlying database, import the data of the structure description file into the database (supporting relational databases and key-value pair databases), initialize the database structure according to the description file, and automatically generate an XML configuration file that is independent of the database.
[0085] S203. Fill in the XML configuration file. According to the functions and actual requirements of metering devices, concentrators or relay devices, manually fill in the initialized configuration file.
[0086] S204. Use a unique XML configuration import program to import the data of the XML configuration file into the database (supporting relational databases and key-value pair databases), and initialize the database data.
[0087] S205. Standard database reading and writing. After initialization, use the marked database reading and writing interfaces to perform reading and writing operations on the database data. The standard interfaces defined externally are independent of the database.
[0088] S30. Standardize the data reading and writing interfaces, and perform the reading and writing design of key-value pair databases and relational databases.
[0089] Specifically, in this embodiment, the ANSI C12.19 protocol defines the transmission structure of protocol table data for data transmission in the ANSI C12.18, ANSI C12.21, and ANSI C12.22 protocols. It is necessary to support the complete data reading and writing process, while shielding the differences in underlying data storage, and providing a unified external data reading and writing process; regardless of what database is used for data storage in the storage layer, a unified standard data reading and writing interface is provided externally. Most of the tables have only one row and no nested structure, supporting reading and writing data according to the table ID (main type) + row number + field (subtype), where the row number and field are optional; for other specific query requirements, the interface can be extended by itself. As shown in Table 3 below:
[0090] Table 3
[0091] Furthermore, in this embodiment, in combination with Figures 5 to 7 , the data in the key-value database is stored in the form of key: value, where key is the data primary key and value is the data value. Data can be quickly read and written through the key, with higher efficiency compared to relational databases; the table name + row number is used as the key, and the default row number is 1 for non-multiple rows of data; the row attribute data is used as the value, and queries are supported by key or by key + attribute name. When the database is initialized, the information of all tables is stored in the key-value database, which is used to record the offset position and length of the table fields for subsequent indexing and data parsing. The key-value data reading and writing process is as follows:
[0092] S301. Index to the data start position according to TableId and row number.
[0093] S302. If operating on the entire row of data, directly read the entire row. If operating on a single field, first obtain the offset position and length of the field.
[0094] S303. Read the specified length of data from the offset position.
[0095] S304. Convert the database data format to the transmission table data format according to the data mapping relationship.
[0096] S305. Convert the transmission data to the storage format data according to the data mapping relationship.
[0097] S306. Determine the key value according to TableId and row number, where the key is the data primary key.
[0098] S307. If the field name is not specified, write the entire row with TableId and row number as the key. If operating on a single field, first obtain the offset position and length of the field, and perform field area data overwrite writing with TableId and row number as the key.
[0099] S308. Return success / failure.
[0100] Furthermore, in this embodiment, in combination with Figures 8 to 10, the data of a relational database is stored in the form of tables, and the table structure includes the table name and the set of table fields; SQL statements are used to perform data insertion, deletion, modification, and query. If the attribute is of the ARRAY structure type, a sub-table 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 are stored in another master table, and other tables are automatically created by reading the table structure data in the master table, and the initialization data is written according to the XML configuration information. Relational databases generally support SQL queries. According to the standard interface definition, standard SQL is automatically assembled according to the query conditions. The relational data reading process is as follows:
[0101] S311. Assemble SQL according to TableId, row number, and field name.
[0102] S312. Execute the assembled SQL to read data.
[0103] S313. Convert the database data format to the transmission table data format according to the data mapping relationship.
[0104] S314. Convert the transmission data to the storage format data according to the data mapping relationship.
[0105] S315. Assemble SQL according to TableId, row number, and field name.
[0106] S316. Execute the assembled SQL to write data.
[0107] S317. Return success / failure.
[0108] Embodiment 1
[0109] The following is the design for Table 04 in Group 0 of ANSI C12.19. Table 04 contains array attributes and a sub-table structure needs to be designed.
[0110] The database structure description file format.xml, and the content example is as follows:
[0111] <allparameter>
[0112] <param>
[0113] <paramname>RECORD04< / paramname>
[0114] <filepath>table04.xml< / filepath>
[0115] <ismulti>false< / ismulti>
[0116] <item>
[0117] <itemname>STANDARD_PENDING< / itemname>
[0118] <type> 5< / type>
[0119] <length> 255< / length>
[0120] < / item>
[0121] <item>
[0122] <itemname>MANUFACT_PENDING< / itemname>
[0123] <type> 5< / type>
[0124] <length> 255< / length>
[0125] < / item>
[0126] <item>
[0127] <itemname>LAST_ACTIVATION_DATE_TIME< / itemname>
[0128] <type> 2< / type>
[0129] <length> 10< / length>
[0130] < / item>
[0131] <item>
[0132] <itemname>NBR_PENDING_ACTIVATION< / itemname>
[0133] <type> 9< / type>
[0134] <length> 1< / length>
[0135] < / item>
[0136]
[0137] <param>
[0138] <paramname>RECORD04_01< / paramname>
[0139] <filepath>table04_01.xml< / filepath>
[0140] <ismulti>true< / ismulti>
[0141] <item>
[0142] <itemname>EVENT__EVENT_SELECTOR< / itemname>
[0143] <type> 5< / type>
[0144] <length> 1< / length>
[0145] < / item>
[0146] <item>
[0147] <itemname>EVENT__EVENT_STORAGE< / itemname>
[0148] <type> 5< / type>
[0149] <length> 5< / length>
[0150] < / item>
[0151] <item>
[0152] <itemname>TABLE_SELECTOR< / itemname>
[0153] <type> 5< / type>
[0154] <length> 2< / length>
[0155] < / item>
[0156]
[0157] < / allparameter>
[0158] Since there are sub-tables, two XML configuration files will be generated. The content of the table04.xml file is as follows:
[0159] <?xml version="1.0" standalone="no" encoding="gb2312"? >
[0160] <allparameter>
[0161] <record04>
[0162] <chgtime> 1119841269< / chgtime>
[0163] <STANDARD_PENDING>00 00< / STANDARD_PENDING>
[0164] <MANUFACT_PENDING>00 01< / MANUFACT_PENDING>
[0165] <LAST_ACTIVATION_DATE_TIME>2411210947< / LAST_ACTIVATION_DATE_TIME>
[0166] <NBR_PENDING_ACTIVATION>1< / NBR_PENDING_ACTIVATION>
[0167]
[0168] < / allparameter>
[0169] The content example of the sub-table file of table04_01.xml is as follows:
[0170] <?xml version="1.0" standalone="no" encoding="gb2312"?>
[0171] <allparameter>
[0172] <RECORD04_01>
[0173] <itemno> 1< / itemno>
[0174] <EVENT__EVENT_SELECTOR>11< / EVENT__EVENT_SELECTOR>
[0175] <EVENT__EVENT_STORAGE>00 00 00 00 00< / EVENT__EVENT_STORAGE>
[0176] <TABLE_SELECTOR>00 0D< / TABLE_SELECTOR>
[0177] < / RECORD04_01>
[0178] <RECORD04_01>
[0179] <itemno> 2< / itemno>
[0180] <EVENT__EVENT_SELECTOR>12< / EVENT__EVENT_SELECTOR>
[0181] <EVENT__EVENT_STORAGE>00 00 00 00 00< / EVENT__EVENT_STORAGE>
[0182] <TABLE_SELECTOR>00 0E< / TABLE_SELECTOR>
[0183] < / RECORD04_01>
[0184] < / allparameter>
[0185] The multi-mode data storage, configuration, and read / write method based on ANSI C12.19 described in the above embodiments, compared with the prior art, in the prior art, it is impossible to simultaneously implement data storage, configuration, and read / write based on the ANSI C12.19 protocol. The process of the present invention is simple and the operation is convenient. It is applicable to the storage and data conversion of data in electric meters, concentrators, and relay devices using the ANSI C12.19 protocol. The ANSI C12.19 table structure is trimmed according to the functions to be implemented, and its data storage method is dynamically configured: storage in key-value pair data format, storage in relational data format; decoupling design between the application layer and the storage layer, and data realizes intelligent conversion of data forms through the establishment of two-way mapping rules, standardizes the storage layer, enables the storage layer to use different storage methods, and the application layer does not need to pay attention to the specific data storage method when reading and writing data, which is convenient for subsequent expansion and speeds up the development and delivery of applications.
[0186] Obviously, the above-described embodiments are only the preferred embodiments of the present invention, rather than all embodiments. The preferred embodiments of the present invention are given in the drawings, but 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 disclosed content of the present invention more thorough and comprehensive. Although the present invention has been described in detail with reference to the foregoing embodiments, for those skilled in the art, they can still modify the technical solutions recorded in the foregoing specific embodiments, or perform equivalent replacements for some of the technical features. Any equivalent structure directly or indirectly using the content of the specification and drawings of the present invention in other related technical fields is equally within the scope of the patent protection of the present invention.
Claims
1. A multi-mode data storage, configuration, reading and writing method based on ANSI C12.19, characterized in that, It includes the following steps: S10. Perform the conversion between transmission data and storage data, and generate a set of mapping relationships between the transmission data structure and the storage data structure according to the attribute data type mapping table; The specific steps for the conversion between transmission data and storage data in step S10 are as follows: S101. Configuration parameter loading: Read the data of Table 00, the FCT table and the FCT+1 table of the current data table group, and for some tables, read the data of other specified data tables; S102. Generation of the mapping relationship between the transmission data structure and the storage data structure: Determine the attributes required in the transmission data structure, the lengths of the attributes, and the parsing / encoding methods according to the configuration parameters read in step S101; S103. Automatic data conversion: After obtaining the mapping relationship between the transmission data structure and the storage structure, perform mutual conversion of the data according to this relationship; S20. Design a unified data structure description file independent of the database, initialize the database, and import the data into the database through the XML configuration import program of the unified data structure description file; S30. Standardize the data read / write interface, and perform the read / write design of the key-value pair database and the read / write design of the relational database.
2. The multi-mode data storage, configuration, reading and writing method based on ANSI C12.19 according to claim 1, characterized in that, The specific steps for generating a set of mapping relationships between the transmission data structure and the storage data structure are as follows: S111. Identify the transmission table ID to be loaded; S112. Load the configuration parameters related to this transmission table, read the data of Table 00, the FCT table and the FCT+1 table of the current data table group, and for some tables, read the data of other specified data tables; S113. Determine the attribute list, attribute lengths, and attribute types, and convert the uncertain table structure defined in the protocol into a definite table structure; S114. Generate a set of mapping relationships between the transmission data structure and the storage data structure according to the attribute data type mapping table.
3. A multi-mode data storage, configuration, 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 step S20 include the table name, the XML file name corresponding to the transmission table, whether it is an array, and the attribute list, where the attribute list includes the attribute name, attribute type, attribute length, and whether it is the primary key.
4. A multi-mode data storage, configuration, reading and writing method based on ANSI C12.19 according to claim 3, characterized in that, The specific process of database initialization is as follows: S201. Design a database structure description file unified and independent of the actual database, and design the database structure according to the transmission table structure of the ANSI C12.19 protocol and the attribute data type mapping table; S202. Use a specific database initialization program to shield the implementation of the underlying database, import the structure description file data into the database, initialize the database structure according to the description file, and automatically generate an XML configuration file independent of the database; S203. Fill in the XML configuration file, and manually fill in the initialized configuration file according to the functions and actual requirements of the metering device, concentrator, or relay device; S204. Use a specific XML configuration import program to import the XML configuration file data into the database to initialize the database data; S205. Standard database read / write: After initialization, use the marked database read / write interface to perform read / write operations on the database data, and the standard interface defined externally is independent of the database.
5. A multi-mode data storage, configuration, reading and writing method based on ANSI C12.19 according to claim 4, characterized in that, The database includes a relational database and a key-value pair database.
6. A multi-mode data storage, configuration, reading and writing method based on ANSI C12.19 according to claim 1, characterized in that, In step S30, data reading and writing are supported according to table ID + row number + field, where the row number and field are optional.
7. A multi-mode data storage, configuration, reading and writing method based on ANSI C12.19 according to claim 6, characterized in that, The function of the table ID is to query / write the first row of data. When only the table ID is input, the default row number is 1, and specific data / success is returned; the function of table ID + row number is to query / write the specified row of data, indicating that the entire row of data is operated on, and specific data / success is returned; the function of table ID + field is to query / write the specified field of the first row, indicating that the data of a certain field in the first row is operated on, and specific data / success is returned; the function of table ID + row number + field is to query / write the specified field of the specified row, indicating that the specified field of the specified row is operated on, and specific data / success is returned.
8. A multi-mode data storage, configuration, reading and writing method based on ANSI C12.19 according to claim 7, characterized in that, The specific process of key-value pair data reading and writing is as follows: S301. Index to the starting position of the data according to the TableId and row number; S302. If the entire row of data is to be operated on, directly read the entire row. If a single field is to be operated on, first obtain the offset position and length of the field; S303. Read the data of the specified length from the offset position; S304. Convert the database data format to the transmission table data format according to the data mapping relationship; S305. Convert the transmitted data to the storage format data according to the data mapping relationship; S306. Determine the key value according to the TableId and row number. The key is the primary key of the data; S307. If the field name is not specified, write the entire row with the TableId and row number as the key. If a single field is to be operated on, first obtain the offset position and length of the field, and overwrite and write the data in the field area with the TableId and row number as the key; S308. Return success / failure.
9. A multi-mode data storage, configuration, reading and writing method based on ANSI C12.19 according to claim 8, characterized in that, The specific process of relational data reading and writing is as follows: S311. Assemble the SQL according to the TableId, row number, and field name; S312. Execute the assembled SQL to read the data; S313. Convert the database data format to the transmission table data format according to the data mapping relationship; S314. Convert the transmitted data to the storage format data according to the data mapping relationship; S315. Assemble the SQL according to the TableId, row number, and field name; S316. Execute the assembled SQL to write the 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
Threat data resource directory updating method and management system
CN118939651A
Form import method, system, device and medium based on dynamic template mapping
CN119761324A
File reading and writing method and system based on XML template and electronic equipment
CN119903024A
Cited By
Load curve data acquisition and pushing method and system
CN122120329A
A method and system for acquiring and transmitting load curve data
CN122120329B
