Disclosure of Invention
In view of the shortcomings of the prior art, an object of the present invention is to provide a simple and effective file management method capable of effectively managing large-capacity data.
A method of file management, the method comprising:
the method comprises the steps that an FPGA receives a writing date information request sent by an upper computer, obtains the initial block address of the storage from an address area of a ROM storage unit according to the writing date information request, obtains date information from a time service module, and writes the obtained date information into an idle area of a FLASH storage unit;
the FPGA receives a user file writing request sent by an upper computer, acquires the initial block address of the storage from the address area of the ROM storage unit according to the user file writing request, and writes user files into the data area of the FLASH storage unit in sequence according to the acquired initial block address;
the FPGA receives a file reading date information request sent by an upper computer, and reads file date information from an idle area of a FLASH storage unit according to the file reading date information request;
the upper computer analyzes and arranges the read file date information to obtain a file date information list;
and the upper computer finds the date information and the initial block address of the required user file from the file information list and reads the user file from the data area of the FLASH storage unit according to the date information and the initial block address of the found user file.
As a further improvement of the invention, before receiving a file writing date information request sent by an upper computer for the first time, the FPGA writes the first address information of the FLASH memory cell into the address area of the ROM memory cell;
after writing the user file into the data area of the FLASH storage unit in sequence at the Nth time (N is an integer greater than or equal to 1), the FPGA updates the address of the address area of the ROM storage unit to the initial block address of the (N + 1) th time data storage.
As a further improvement of the present invention, the method further comprises: and writing the configuration information of the ROM storage unit and the FLASH storage unit into a configuration area of the ROM storage unit.
As a further improvement of the invention, the configuration information at least comprises the capacities of the ROM storage unit and the FLASH storage unit, the capacity of the configuration area, the initial address of the configuration area, the capacity of the address area, the initial address of the address area, the capacity of the data area, the initial address of the data area, the number of bytes of a complete frame structure, a frame structure table and a sampling control rate.
As a further improvement of the present invention, writing the user file data into the data area of the FLASH memory unit in sequence according to the obtained starting block address specifically includes:
when writing a block, judging whether the storage space of the next block is empty, if so, erasing the data of the next block, and writing the user file into the data area of the FLASH storage unit in sequence, otherwise, directly writing the user file data into the data area of the FLASH storage unit in sequence.
As a further improvement of the invention, when a recording stopping command or sudden power failure sent by an upper computer is received, the power supply module provides electric energy to completely write the user files cached in the data area of the FLASH storage unit and update the address information in the address area of the ROM storage unit, wherein the address information comprises the initial block address and the number of blocks occupied by the user files.
As a further improvement of the present invention, the reading the user file from the data area of the FLASH memory unit according to the date information and the start block address of the found user file specifically includes: when a block is read, judging whether the block is the last block, if so, stopping reading after the block is read; otherwise, after reading the block, continuing to read the next block.
It is a second object of the present invention to provide a file management system which is simple and effective and can efficiently manage large-capacity data.
A file management system, the system comprising: the method comprises the following steps: the system comprises an upper computer, an FPGA, a time service module and a data storage module, wherein the data storage module comprises a ROM storage unit and a FLASH storage unit;
the storage unit of the ROM is divided into a configuration area and an address area, the FLASH storage unit is divided into a data area and an idle area, the configuration area is used for storing configuration information of the data storage module, and the address area is used for storing a starting block address of a user file and the number of blocks occupied by the user file; the data area is used for storing user files; the free area is used for storing date information;
the upper computer is used for sending a date writing information request to the FPGA;
the FPGA is used for receiving the writing date information request, acquiring the initial block address of the current storage from the address area according to the writing date information request, acquiring date information from the time service module, and writing the acquired date information into the corresponding page of the idle area;
the time service module is used for providing date information;
the upper computer is also used for sending a user file writing request to the FPGA;
the FPGA is also used for receiving a user file writing request, acquiring the initial block address of the storage from the address area according to the user file writing request, and writing user files into the data area in sequence according to the acquired initial block address;
the upper computer is also used for sending a file reading date information request to the FPGA;
the FPGA is also used for receiving the file reading date information request and reading date information from the idle area according to the file reading date information request;
the upper computer is also used for analyzing and sorting the read date information to obtain a file date information list;
the upper computer is also used for finding the date information and the starting block address of the required user file from the file date information list and reading the user file from the data area according to the date information and the starting block address of the found user file.
As a further improvement of the present invention, the FPGA is further configured to:
before a file writing date information request sent by an upper computer is received for the first time, writing the first address information of the FLASH storage unit into an address area of the ROM storage unit;
after writing the user file into the data area of the FLASH memory unit in sequence the Nth time (N is an integer greater than or equal to 1), the address of the address area of the ROM memory unit is updated to the initial block address of the data storage of the (N + 1) th time.
As a further improvement of the present invention, the system further comprises: and the power supply module is used for providing electric energy to write the user files cached in the data area of the FLASH storage unit and update the address information in the address area of the ROM storage unit when a recording stopping command or sudden power failure sent by the upper computer is received.
The invention has the beneficial effects that:
the invention stores user files by using a FLASH data area, stores file date information by using a FLASH idle area, stores configuration information by using a ROM configuration area, stores the initial block address of the user files by using a ROM address area, obtains a user file information list by obtaining the file date information of the idle area, reads the initial block address stored by the user files in the file information list, and can determine the storage position of the required user files according to the initial address corresponding to the date information, thereby realizing the visual selective reading of the user data by an upper computer.
The foregoing description is only an overview of the technical solutions of the present invention, and in order to make the technical means of the present invention more clearly understood, the present invention may be implemented in accordance with the content of the description, and in order to make the above and other objects, features, and advantages of the present invention more clearly understood, the following preferred embodiments are described in detail with reference to the accompanying drawings.
Detailed Description
The present invention is further described below in conjunction with the following figures and specific examples so that those skilled in the art may better understand the present invention and practice it, but the examples are not intended to limit the present invention.
As shown in fig. 1, in the embodiment of the present invention, the method includes the following steps:
step S110, the FPGA receives a writing date information request sent by an upper computer, acquires the initial block address of the current storage from the address area of the ROM storage unit according to the writing date information request, acquires date information from the time service module, and writes the acquired date information into the idle area of the FLASH storage unit;
wherein the date information is stored in each page of each block corresponding to the user data. Writing the obtained date address into the idle area as the idle area corresponding to the obtained initial block address; the time service module is a GPS time service module, the format of the date information is year, month, day, hour, minute and second milliseconds, 11 bits are occupied every year, 4 bits are occupied every month, 5 bits are occupied every day, 5 bits are occupied every hour, 6 bits are occupied every minute, 6 bits are occupied every second, 6 bits are occupied every millisecond, and 43 bits are occupied every page of the free area, namely, six bytes are occupied at most.
Preferably, before the step S110 is executed for the first time, the method further includes the following steps:
writing the configuration information of the ROM storage unit and the FLASH storage unit into a configuration area of the ROM storage unit;
specifically, the configuration information includes capacities of the ROM storage unit and the FLASH storage unit, a configuration area capacity, a configuration area start address, an address area capacity, an address area start address, a data area capacity, a data area start address, a number of bytes of a complete frame structure, a frame structure table, and the like.
Preferably, before the step S110 is executed for the first time, the method further includes the following steps:
and the FPGA writes the first address information of the FLASH storage unit into the address area of the ROM storage unit.
The acquired file information list contains the start block address of the user file storage, and the free area does not store the start address of the user file, so that the first address information of the data storage is required to be written back to the file list at the beginning.
Step S120, the FPGA receives a user file writing request sent by an upper computer, obtains the initial block address of the storage from the address area of the ROM storage unit according to the user file writing request, and writes user files into the data area of the FLASH storage unit according to the obtained initial block address in sequence;
preferably, after each user file writing, if the block storage space is not fully written, the next data storage after power failure is directly written from the next block.
After the user files are sequentially written into the data area of the FLASH storage unit for the Nth time (N is an integer which is more than or equal to 1), the address of the address area of the ROM storage unit is updated to the initial block address of the data storage for the (N + 1) th time by the FPGA.
The writing of the user file data into the data area of the FLASH memory unit in sequence according to the obtained starting block address specifically includes: when writing a block, judging whether the storage space of the next block is empty, if so, erasing the data of the next block, and writing the user file into the data area of the FLASH storage unit in sequence, otherwise, directly writing the user file data into the data area of the FLASH storage unit in sequence.
Step S130, the FPGA receives a file reading date information request sent by an upper computer, and reads file date information from an idle area of a FLASH storage unit according to the file reading date information request;
step S140, the upper computer analyzes and arranges the read file date information to obtain a file date information list;
the file date information list is composed of the starting time and the ending time of writing the user file, the first address of storing the data and the like.
And step S150, the upper computer finds the date information and the initial block address of the required user file from the file information list, and reads the user file from the data area of the FLASH storage unit according to the date information and the initial block address of the found user file.
Reading the user file from the data area of the FLASH storage unit according to the date information and the starting block address of the found user file, which specifically comprises the following steps: when a block is read, judging whether the block is the last block, if so, stopping reading after the block is read; otherwise, after reading the block, continuing to read the next block.
Preferably, the method further comprises the steps of:
when a recording stopping command or sudden power failure sent by the upper computer is received, the power supply module provides electric energy to completely write the user files cached in the data area of the FLASH storage unit and update the address information in the address area of the ROM storage unit. The address information includes a start block address.
Preferably, the FLASH memory unit is NAND FLASH mass storage.
The present invention also includes a file management system, comprising: the device comprises an upper computer, an FPGA, a time service module and a data storage module, wherein the data storage module comprises a ROM storage unit and a FLASH storage unit.
The ROM storage unit is divided into a configuration area and an address area, the configuration area is used for storing configuration information of the data storage module, and the address area is used for storing a starting block address of a user file and the number of blocks occupied by the user file;
as shown in fig. 2, the FLASH memory unit includes a plurality of blocks, each block includes a plurality of pages, each page includes a data area for storing user files and a free area for storing date information.
The upper computer is used for sending a date writing information request to the FPGA; the time service module is used for providing date information;
the FPGA is used for receiving the writing date information request, acquiring the initial block address of the current storage from the address area according to the writing date information request, acquiring date information from the time service module, and writing the acquired date information into the corresponding page of the idle area;
wherein the date information is stored in each page of each block corresponding to the user data. Writing the obtained date address into the idle area as the idle area corresponding to the obtained initial block address; the time service module is a GPS time service module, the format of the date information is year, month, day, hour, minute and second milliseconds, 11 bits are occupied every year, 4 bits are occupied every month, 5 bits are occupied every day, 5 bits are occupied every hour, 6 bits are occupied every minute, 6 bits are occupied every second, 6 bits are occupied every millisecond, and 43 bits are occupied every page of the free area, namely, six bytes are occupied at most.
The upper computer is also used for sending a user file writing request to the FPGA;
the FPGA is also used for receiving a user file writing request, acquiring the initial block address of the storage from the address area according to the user file writing request, and writing the user files into the data area according to the acquired initial block address in sequence;
the writing of the user file data into the data area in sequence according to the obtained starting block address specifically includes: when writing a block, judging whether the storage space of the next block is empty, if so, erasing the data of the next block, and writing the user file into the data area of the FLASH storage unit in sequence, otherwise, directly writing the user file data into the data area of the FLASH storage unit in sequence.
Preferably, after each user file writing, if the block storage space is not fully written, the next data storage after power failure is directly written from the next block.
The upper computer is also used for sending a file reading date information request to the FPGA;
the FPGA is also used for receiving the file reading date information request and reading date information from the idle area according to the file reading date information request;
the upper computer is also used for analyzing and sorting the read date information to obtain a file date information list;
the file date information list is composed of the starting time and the ending time of writing the user file, the first address of storing the data and the like.
The upper computer is also used for finding the date information and the starting block address of the required user file from the file date information list and reading the user file from the data area according to the date information and the starting block address of the found user file.
Reading the user file from the data area of the FLASH storage unit according to the date information and the starting block address of the found user file, which specifically comprises the following steps: when a block is read, judging whether the block is the last block, if so, stopping reading after the block is read; otherwise, after reading the block, continuing to read the next block.
Preferably, the FPGA is further configured to:
before a write date information request sent by an upper computer is received for the first time, the first address information of the FLASH storage unit is written into an address area of the ROM storage unit.
The acquired file information list contains the start block address of the user file storage, and the free area does not store the start address of the user file, so that the first address information of the data storage is required to be written back to the file list at the beginning.
After writing the user file into the data area of the FLASH storage unit in sequence at the Nth time (N is an integer greater than or equal to 1), the FPGA updates the address of the address area of the ROM storage unit to the initial block address of the (N + 1) th time data storage.
Preferably, the system further comprises a power module, wherein the power module is used for providing electric energy to complete writing of the user file cached in the data area of the FLASH memory unit and update the address information in the address area of the ROM memory unit when a recording stopping command or sudden power failure sent by the upper computer is received.
Preferably, the FLASH memory unit is NAND FLASH mass storage.
The invention has the beneficial effects that:
the invention stores user files by using a FLASH data area, stores file date information by using a FLASH idle area, stores configuration information by using a ROM configuration area, stores the initial block address of the user files by using a ROM address area, obtains a user file information list by obtaining the file date information of the idle area, reads the initial block address stored by the user files in the file information list, and can determine the storage position of the required user files according to the initial address corresponding to the date information and the number of blocks occupied by the user files, thereby realizing the visual selective reading of the user data by an upper computer.
The above embodiments are merely preferred embodiments for fully illustrating the present invention, and the scope of the present invention is not limited thereto. The equivalent substitution or change made by the technical personnel in the technical field on the basis of the invention is all within the protection scope of the invention. The protection scope of the invention is subject to the claims.