Electric energy meter data management method, electric energy meter and computer readable storage medium

文档序号:7383 发布日期:2021-09-17 浏览:39次 中文

1. A method for managing electric energy meter data, characterized in that the method comprises:

establishing a virtual file corresponding to the system file;

when the virtual file is modified, establishing a replacement file corresponding to the modified content;

and replacing the system file corresponding to the modified content with the replacement file.

2. The electric energy meter data management method according to claim 1, wherein the number of the system files is at least one, and the step of creating the virtual file corresponding to the system file comprises:

and establishing management information corresponding to the system files one by one.

3. The method for managing electric energy meter data according to claim 2, wherein the step of creating a replacement file corresponding to the modified contents when the virtual file is modified comprises:

when the virtual file content corresponding to the management information is modified, establishing a replacement file corresponding to the management information;

the step of replacing the system file corresponding to the modified content with the replacement file includes:

and replacing the system file corresponding to the management information with the replacement file.

4. The electric energy meter data management method according to claim 3, wherein the step of creating a replacement file corresponding to the management information comprises:

copying the system file corresponding to the management information to obtain a copied file corresponding to the system file;

and modifying the copied file according to the modified content to obtain the replacement file.

5. The electric energy meter data management method according to claim 4, wherein the step of replacing the system file corresponding to the management information with the replacement file comprises:

releasing the corresponding relation between the management information and the system file;

and establishing a corresponding relation between the management information and the replacement file, and deleting the system file corresponding to the replacement file.

6. The method for managing power meter data of claim 5, wherein said method further comprises:

when the electric energy meter is started, judging whether a system file which does not establish a connection relation with any management information exists;

and if so, deleting the system file which does not establish the connection relation with any management information.

7. The method for managing electric energy meter data according to claim 2, wherein the step of creating a replacement file corresponding to the modified contents comprises, before:

judging whether the number of the modified management information is larger than 1;

if not, modifying the system file according to the modification content;

if yes, executing the following steps: and establishing a replacement file corresponding to the modified content.

8. The electric energy meter data management method according to any one of claims 1 to 7, characterized by further comprising:

when the electric energy meter is started, judging whether the virtual file is consistent with the system file;

if not, the virtual file is restored to be consistent with the system file.

9. An electric energy meter, characterized in that it comprises a memory, a processor and a computer program stored on said memory and executable on said processor, said computer program, when executed by said processor, implementing the steps of the electric energy meter data management method according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps of the electric energy meter data management method according to any one of claims 1 to 8.

Background

In the conventional electric energy management company, little files are introduced to the next generation of internet of things electric energy meter as a file system for data management, and the system adopts a mode of combining a COW (Copy On Write) mechanism and a log to protect the power failure safety, but the file system of the COW mechanism has the problem of storage and Write delay, and when the file volume is large, the Write delay is very large, which is unacceptable for the electric energy meter with limited resources.

Disclosure of Invention

The invention mainly aims to provide an electric energy meter data management method, an electric energy meter and a computer readable storage medium, and aims to solve the problem that the write-in delay of a file system of a COW mechanism in the prior art is large.

In order to achieve the above object, the present invention provides a method for managing data of an electric energy meter, the method comprising the steps of:

establishing a virtual file corresponding to the system file;

when the virtual file is modified, establishing a replacement file corresponding to the modified content;

and replacing the system file corresponding to the modified content with the replacement file.

Optionally, the number of the system files is at least one, and the step of creating a virtual file corresponding to a system file includes:

and establishing management information corresponding to the system files one by one.

Optionally, when the virtual file is modified, the step of creating a replacement file corresponding to the modified content includes:

when the virtual file content corresponding to the management information is modified, establishing a replacement file corresponding to the management information;

the step of replacing the system file corresponding to the modified content with the replacement file includes:

and replacing the system file corresponding to the management information with the replacement file.

Optionally, the step of creating a replacement file corresponding to the management information includes:

copying the system file corresponding to the management information to obtain a copied file corresponding to the system file;

and modifying the copied file according to the modified content to obtain the replacement file.

Optionally, the step of replacing the system file corresponding to the management information with the replacement file includes:

releasing the corresponding relation between the management information and the system file;

and establishing a corresponding relation between the management information and the replacement file, and deleting the system file corresponding to the replacement file.

Optionally, the method further comprises:

when the electric energy meter is started, judging whether a system file which does not establish a connection relation with any management information exists;

and if so, deleting the system file which does not establish the connection relation with any management information.

Optionally, the step of creating a replacement file corresponding to the modified content includes:

judging whether the number of the modified management information is larger than 1;

if not, modifying the system file according to the modification content;

if yes, executing the following steps: and establishing a replacement file corresponding to the modified content.

Optionally, the method further comprises:

when the electric energy meter is started, judging whether the virtual file is consistent with the system file;

if not, the virtual file is restored to be consistent with the system file.

To achieve the above object, the present invention further provides an electric energy meter, which includes a memory, a processor, and a computer program stored on the memory and operable on the processor, wherein the computer program, when executed by the processor, implements the steps of the electric energy meter data management method as described above.

To achieve the above object, the present invention also provides a computer-readable storage medium having stored thereon a computer program, which when executed by a processor, implements the steps of the electric energy meter data management method as described above.

The invention provides an electric energy meter data management method, an electric energy meter and a computer readable storage medium, wherein a virtual file corresponding to a system file is established; when the virtual file is modified, establishing a replacement file corresponding to the modified content; and replacing the system file corresponding to the modified content with the replacement file. By mapping the virtual file corresponding to the system file, when the user modifies the virtual file, the user only needs to read and write the system file corresponding to the modified part, so that the size of the read and write file can be reduced, and the write-in delay is reduced.

Drawings

FIG. 1 is a schematic flow chart illustrating a first embodiment of a method for managing data of an electric energy meter according to the present invention;

fig. 2 is a detailed flowchart of step S22 of the electric energy meter data management method according to the fourth embodiment of the present invention;

fig. 3 is a schematic diagram of a module structure of the electric energy meter according to the present invention.

Detailed Description

It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

The invention provides an electric energy meter data management method, referring to fig. 1, fig. 1 is a schematic flow chart of a first embodiment of the electric energy meter data management method of the invention, and the method comprises the following steps:

step S10, establishing a virtual file corresponding to the system file;

the embodiment introduces the concept of the virtual file layer, and the user does not directly operate the actual system file, but operates the virtual file corresponding to the actual system file by using the function interfaces such as open, close, read, write and the like provided by the virtual file layer. It should be noted that the virtual file may be an image file that is identical to the system file in data, or may be a mapping file that has a mapping relationship with only the system file.

Step S20, when the virtual file is modified, a replacement file corresponding to the modified content is established;

when the virtual file is modified, the actual user will modify the system file, so that the system file needs to be further modified according to the modification content of the virtual file; however, in the actual use process, if the system file is directly modified, when the system is shut down due to power failure of the electric energy meter or the like in the modification process, the system file is not modified completely, so that the system file is in error, and even the system fails. Therefore, in the embodiment, when the system file is modified, the modification operation is not directly performed on the system file to be modified, but a replacement file corresponding to the modified system file is newly created, so that even if the system is closed in the process of creating the replacement file, the system file itself is not affected, and the situation that the system is closed when the system file is not modified so as to cause a system file error or a system failure is avoided.

And step S30, replacing the system file corresponding to the modified content with the replacement file.

After the replacement file is established, the replacement file is the file which is correspondingly modified on the basis of the original system file, and the modification operation can be completed by replacing the system file with the replacement file.

When the step of establishing the virtual file corresponding to the system file is executed, if the system is closed, no modification operation is carried out on the system file, so that the condition that the system is closed to cause system file errors or system faults can not occur, and meanwhile, the step of establishing the virtual file corresponding to the system file can be continuously executed after the system is started; when the step of establishing the replacement file corresponding to the modified content is executed, if the system is closed, no modification operation is still performed on the system file, so that the condition that the system is closed to cause system file errors or system faults does not occur, and meanwhile, the step of establishing the replacement file corresponding to the modified content can be continuously executed after the system is started; when the step of replacing the system file corresponding to the modified content with the replacement file is performed, if a system is closed, although the system file is replaced, the system file itself is not modified, so that the situation that the system file is wrong or the system fails due to system closing does not occur, and meanwhile, the original system file is still used as the system file after the system is started.

In the embodiment, the virtual file corresponding to the system file is mapped, and when the user modifies the virtual file, the user only needs to read and write the system file corresponding to the modified part, so that the size of the read and write file can be reduced, and the write-in delay is reduced.

Further, in a second embodiment of the electric energy meter data management method according to the present invention based on the first embodiment of the present invention, the number of the system files is at least one, and the step S20 includes the steps of:

step S21, management information corresponding to the system files one to one is established.

The system in this embodiment is a Littlefs file system. Files in the Littlefs file system exist in the form of data BLOCKs BLOCK, the maximum storage data volume of each data BLOCK is certain, data are stored in sequence, when the data stored in one data BLOCK reaches a limit value, a new data BLOCK is added, meanwhile, a pointer of the new data BLOCK points to an old data BLOCK, and meanwhile, the information of the new data BLOCK is synchronously updated into metadata.

The management information corresponds to the system files one by one, and the pointer of the management information points to the corresponding system files.

In the prior art, a scheme exists in which a system file is used as one file, and a plurality of virtual files are simultaneously established to correspond to the system file, but the scheme of the embodiment is that the system file is set to be a plurality of files, and one virtual file is simultaneously established to respectively correspond to the plurality of system files so as to reduce the writing of the files; specifically, the method comprises the following steps: the following description is made of a system file including N M-sized files:

in the case where the data of the system file is full, X bytes of data of the system file at the beginning need to be modified. In the prior art, M data blocks need to be erased, data with the size of N × M needs to be written, and metadata is updated once; in this embodiment, only 1 flash block needs to be erased, and N bytes of data are written while the metadata is updated once.

In the case that the system file data is full, 2X bytes of data with system file offsets N-X to N + X need to be modified. In the prior art, M data blocks need to be erased, data with the size of N × M needs to be written, and metadata is updated once; in the present embodiment, only 2 data blocks need to be erased, and 2 × N bytes of data are written, and the four-time metadata is updated.

In the case that the system file data is full, X bytes of data of the last system file need to be modified. In the prior art, 1 data block needs to be erased, data with the size of N bytes needs to be written, and metadata needs to be updated once. In this embodiment, 1 flash block needs to be erased, and data with the size of N bytes needs to be written, and metadata needs to be updated once.

In the case of a full system file, 2X bytes of data are modified for a system file offset of (M-1) N-X to (M-1) N + X. In the prior art, 2 data blocks need to be erased, data with the size of N × 2 needs to be written, and metadata needs to be updated once; in this embodiment, 2 flash blocks need to be erased, 2 × N bytes of data are written, and the metadata is updated four times. For littlefs, one write of metadata is 12 bytes.

In this embodiment, the writing operation of littlefs requires erasing data of 2 data blocks at most, writing data of 2 data blocks, and writing data of 1 data block at minimum.

The embodiment can reasonably establish the virtual layer corresponding to each system file in the Littlefs file system.

Further, in a third embodiment of the electric energy meter data management method according to the present invention based on the second embodiment of the present invention, the step S20 includes the steps of:

step S22, when the virtual file content corresponding to the management information is modified, a replacement file corresponding to the management information is established;

step S23, the step of replacing the system file corresponding to the modified content with the replacement file includes:

in step S24, the system file corresponding to the management information is replaced with the replacement file.

When the virtual file is modified, acquiring management information related to modification in the virtual file, and simultaneously establishing a replacement file corresponding to the management information, so as to replace the system file corresponding to the management information with the replacement file. By modifying only the system file corresponding to the management information related to the modification, the number of reading times can be reduced, and the modified system file can be reduced, thereby improving the modification speed. The embodiment can make the writing time delay relatively average.

Further, referring to fig. 2, in a fourth embodiment of the electric energy meter data management method according to the present invention based on the third embodiment of the present invention, the step S22 includes the steps of:

step S221, copying the system file corresponding to the management information to obtain a copied file corresponding to the system file;

step S222, modifying the copied file according to the modified content to obtain the replacement file.

It is understood that, in addition to copying the system file corresponding to the management information to obtain the copied file, the management information may be directly copied to obtain the copied file, and then the corresponding modification operation may be performed on the copied file to obtain the replacement file.

In other embodiments, the management information may be directly modified, and then the modified management information may be copied to obtain a copied file.

The embodiment can reasonably establish the replacement file.

Further, in a fifth embodiment of the electric energy meter data management method according to the present invention based on the fourth embodiment of the present invention, the step S24 includes the steps of:

step S241, releasing the correspondence between the management information and the system file;

step S242, establishing a corresponding relationship between the management information and the replacement file, and deleting the system file corresponding to the replacement file.

And binding the corresponding relation between the management information and the system file in a pointer mode. Specifically, the way of releasing the corresponding relationship between the management information and the system file and establishing the corresponding relationship between the management information and the replacement file is to change the pointer of the management information from the value system file to the value system file. And after the corresponding relation is changed, the original replacement file becomes a new system file, the system file is not bound with any management information at the moment, and the system file is deleted after the modification operation is finished.

In this step, if the system is closed when the pointer replacement operation is performed, the management information is restored to the current system file because the management information is inconsistent with the original system file when the system is restarted, and the pointer also points to the system file at this time.

The embodiment can reasonably replace the system file with the replacement file.

Further, in a sixth embodiment of the electric energy meter data management method according to the present invention based on the fifth embodiment of the present invention, the method further includes the steps of:

step S40, when the electric energy meter is started, judging whether a system file which does not establish a connection relation with any management information exists;

and step S50, if yes, deleting the system file which is not connected with any management information.

After the pointer replacement operation is completed, the pointer of the management information points to the replacement file, the original system file is not bound with any management information, and if the system is closed at the moment, the original system file is not subjected to deletion operation; therefore, when the electric energy meter is started, if the system file which is not connected with any management information is detected, the system file is indicated to be replaced, and the deleting operation can be executed on the system file.

According to the embodiment, the system file which is not connected with any management information is deleted when the electric energy meter is started, so that the problem that the modified system file occupies a storage space can be avoided.

Further, in a seventh embodiment of the electric energy meter data management method according to the present invention proposed based on the second embodiment of the present invention, before the step S20, the method includes the steps of:

step S60, determining whether the number of modified management information is greater than 1;

step S70, if not, modifying the system file according to the modified content;

in step S80, if yes, the method proceeds to: and establishing a replacement file corresponding to the modified content.

When the number of management information relating to modification is not more than 1, that is, there is no modified management information or only one management information relating to modification, there is no modified management information and no modification operation needs to be performed; however, when only one piece of management information is involved in modification, the number of read/write operations required by the existing file modification method is small, and in this case, if a method of creating a new replacement file and replacing the system file with the replacement file is adopted, the number of write operations in the current operation is increased. Therefore, when only one piece of management information related to modification exists, the modification operation is directly carried out in the system file at the bottom layer, and the management information is correspondingly updated.

The present embodiment makes it possible to avoid increasing the number of writes when the number of management information relating to modification is 1, by distinguishing whether the number of management information relating to modification is 1 or more than one.

Further, in an eighth embodiment of the electric energy meter data management method according to the present invention based on the first embodiment of the present invention, the method further includes the steps of:

step S90, when the electric energy meter is started, judging whether the virtual file is consistent with the system file;

and S100, if not, restoring the virtual file to be consistent with the system file.

When the virtual file is inconsistent with the system file when the electric energy meter is started, the situation that the system is powered off after the step of modifying the management information, the corresponding relation between the management information and the replacement file is established, and the system file corresponding to the replacement file is deleted is explained, at the moment, in order to ensure the consistency of data, the management information is restored, so that the management information is consistent with the system file.

The embodiment can ensure the consistency of the management information and the system file.

Referring to fig. 3, the electric energy meter may include components of a communication module 10, a memory 20, and a processor 30 in a hardware structure. In the electric energy meter, the processor 30 is connected to the memory 20 and the communication module 10, respectively, the memory 20 stores thereon a computer program, which is executed by the processor 30 at the same time, and when executed, implements the steps of the above-mentioned method embodiment.

The communication module 10 may be connected to an external communication device through a network. The communication module 10 may receive a request from an external communication device, and may also send a request, an instruction, and information to the external communication device, where the external communication device may be another electric energy meter, a server, or an internet of things device, such as a television.

The memory 20 may be used to store software programs as well as various data. The memory 20 may mainly include a storage program area and a storage data area, where the storage program area may store an operating system, an application program required by at least one function (for example, establishing a corresponding relationship between the management information and the replacement file, and deleting a system file corresponding to the replacement file), and the like; the storage data area may include a database, and the storage data area may store data or information created according to use of the system, or the like. Further, the memory 20 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.

The processor 30, which is a control center of the electric energy meter, connects various parts of the whole electric energy meter by using various interfaces and lines, and performs various functions of the electric energy meter and processes data by operating or executing software programs and/or modules stored in the memory 20 and calling data stored in the memory 20, thereby performing overall monitoring of the electric energy meter. Processor 30 may include one or more processing units; alternatively, the processor 30 may integrate an application processor, which primarily handles operating systems, user interfaces, applications, etc., and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 30.

Although not shown in fig. 3, the electric energy meter may further include a circuit control module, which is used for connecting with a power supply to ensure the normal operation of other components. Those skilled in the art will appreciate that the power meter configuration shown in fig. 3 does not constitute a limitation of the power meter and may include more or fewer components than shown, or some components may be combined, or a different arrangement of components.

The invention also proposes a computer-readable storage medium on which a computer program is stored. The computer-readable storage medium may be the Memory 20 in the electric energy meter of fig. 3, and may also be at least one of a ROM (Read-Only Memory)/RAM (Random Access Memory), a magnetic disk, and an optical disk, where the computer-readable storage medium includes instructions for enabling a terminal device (which may be a television, an automobile, a mobile phone, a computer, a server, a terminal, or a network device) having a processor to execute the method according to the embodiments of the present invention.

In the present invention, the terms "first", "second", "third", "fourth" and "fifth" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance, and those skilled in the art can understand the specific meanings of the above terms in the present invention according to specific situations.

In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.

Although the embodiment of the present invention has been shown and described, the scope of the present invention is not limited thereto, it should be understood that the above embodiment is illustrative and not to be construed as limiting the present invention, and that those skilled in the art can make changes, modifications and substitutions to the above embodiment within the scope of the present invention, and that these changes, modifications and substitutions should be covered by the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:一种服务故障动态调控方法与系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!