Data reading and writing method and device for automatic train control system
By using ferroelectric memory and partitioned block verification in the ATC system, the problem of low data reading and writing rates in the ATC system is solved, fast and reliable data reading and writing and redundant backup are achieved, and system performance and user experience are improved. .
Patent Information
- Application Number
- CN201911109204.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-11-13
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2039-11-13
AI Technical Summary
The data reading and writing rate in the existing ATC system is low, which affects the device startup speed and storage efficiency, and parameter data may be lost when power supply or power outage occurs.
Ferroelectric memory is used and partitioned into the first area and the second area. Each area is divided into index identification, data block and check code sub-area. Data is read and written through partition block verification to achieve redundant backup and automatic repair. .
It improves the speed and reliability of data reading and writing, ensures the integrity of parameter data and system performance, avoids data loss, and improves user experience and system availability.
Smart Images

Figure CN110941394B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of rail transit technology, and in particular to a method and device for reading and writing data of a train automatic control system. Background Art
[0002] The Automatic Train Control (ATC) system is an important part of the railway signal system, which undertakes the important functions of safe train operation and automatic driving. During the operation of the ATC system, a large amount of data needs to be stored and recorded, mainly including the following types of data: software program data, equipment parameter data, equipment status data, and operation record data.
[0003] In the prior art, software programs are usually stored in Flash chips, device parameter data are usually stored in electrically erasable programmable read-only memory (EEPROM), device status data and operation record data are usually stored in additional recording boards, and the storage medium of the recording board can be implemented in a variety of ways, such as Flash chips, solid-state drives (SSDs), hard disk drives (HDs), CF cards, and SD cards.
[0004] However, in actual engineering applications, since the performance indicators of each vehicle cannot be exactly the same, and different train IDs are used to distinguish different trains, the device parameter data in each onboard ATC must be different, and each ATC device has a unique set of parameters. At present, the storage device parameter data is mostly stored in EEPROM, but due to the limitations of the EEPROM storage principle and the speed of serial communication protocols such as SPI and I2C, the reading and writing of parameter data is slow, which will affect the device startup speed, storage efficiency and user experience. In addition, the operation of trains is relatively complex, and power supply may be frequently switched or cut off without warning, which requires that parameter reading and writing must be not only reliable but also fast to avoid incomplete or lost parameter data records due to power outages. Summary of the invention
[0005] The embodiment of the present invention provides a method and device for reading and writing data of an automatic train control system, which are used to solve the technical problem of low data reading and writing rate of an ATC system in the prior art.
[0006] In order to solve the above technical problems, on the one hand, an embodiment of the present invention provides a method for reading and writing data of a train automatic control system, comprising:
[0007] Receiving read and write instruction information for target data, wherein the read and write instruction information includes a target address in the ferroelectric memory corresponding to the target data;
[0008] According to the target address, determining the number of the target data block corresponding to the target address in the ferroelectric memory;
[0009] Based on the serial number of the target data block, performing a read and write operation on the target data;
[0010] In which, the ferroelectric memory is divided into two large areas, a first area and a second area, each large area is divided into at least three sub-areas, a first sub-area, a second sub-area and a third sub-area, and the data stored in each sub-area in the first area is exactly the same as the data stored in the corresponding sub-area in the second area, so that the first area and the second area back up each other, the first sub-area is used to store index identifiers, the second sub-area is used to store data blocks of a preset size, and the third sub-area is used to store check codes corresponding to the index identifiers and check codes corresponding to the data blocks.
[0011] Further, the step of determining the number of the target data block corresponding to the target address in the ferroelectric memory according to the target address specifically includes:
[0012] Searching for an index identifier in a first sub-area of a first area of the ferroelectric memory to determine a serial number of the target data block;
[0013] The index identifier includes the starting address, the ending address and the serial number of each data block in the second sub-area, and the target address is between the starting address and the ending address of the target data block.
[0014] Further, the performing of the read and write operations on the target data based on the serial number of the target data block specifically includes:
[0015] When a read operation is performed on the target data, the following steps are performed:
[0016] Reading the target data block from the second sub-area of the first area of the ferroelectric memory based on the number of the target data block, and reading a check code corresponding to the target data block from the third sub-area of the first area of the ferroelectric memory;
[0017] If the check code calculated based on the target data block currently read is the same as the check code currently read, the target data is extracted from the target data block currently read, and a read success flag is returned.
[0018] Further, the performing of the read and write operations on the target data based on the serial number of the target data block specifically includes:
[0019] When a read operation is performed on the target data, the following steps are performed:
[0020] Reading the target data block from the second sub-area of the first area of the ferroelectric memory based on the number of the target data block, and reading a check code corresponding to the target data block from the third sub-area of the first area of the ferroelectric memory;
[0021] If the check code calculated based on the target data block currently read is different from the check code currently read, the target data currently read and the check code currently read are discarded;
[0022] again reading the target data block from the second sub-area of the second area of the ferroelectric memory based on the number of the target data block, and reading a check code corresponding to the target data block from the third sub-area of the second area of the ferroelectric memory;
[0023] If the check code calculated based on the target data block currently read is the same as the check code currently read, the target data is extracted from the target data block currently read, and a read success flag is returned.
[0024] Further, the performing of the read and write operations on the target data based on the serial number of the target data block specifically includes:
[0025] When a write operation is performed on the target data, the following steps are performed:
[0026] Reading the target data block from the second sub-area of the first area of the ferroelectric memory based on the number of the target data block, and reading a check code corresponding to the target data block from the third sub-area of the first area of the ferroelectric memory;
[0027] If the check code calculated based on the target data block currently read is the same as the check code currently read, the target data is written into the position of the target address in the target data block to obtain a new data block;
[0028] The target data is written into the ferroelectric memory based on a new data block.
[0029] Further, the step of writing the target data into the ferroelectric memory based on the new data block specifically includes:
[0030] storing the new data block in the second sub-area of the first area and the second sub-area of the second area of the ferroelectric memory respectively;
[0031] Calculate a new checksum based on the new data block;
[0032] The check codes corresponding to the target data block stored in the third sub-area of the first area and the third sub-area of the second area of the ferroelectric memory are replaced with new check codes, and a write success flag is returned.
[0033] Further, the step of writing the target data into the ferroelectric memory based on the new data block specifically includes:
[0034] Calculate a new checksum based on the new data block;
[0035] storing a new data block in the second sub-area of the first area of the ferroelectric memory, and replacing the check code corresponding to the target data block stored in the third sub-area of the first area of the ferroelectric memory with a new check code;
[0036] Reading the new data block from the second sub-area of the first area of the ferroelectric memory, and reading the new check code from the third sub-area of the first area of the ferroelectric memory;
[0037] If the check code calculated based on the new data block currently read is the same as the new check code currently read, the new data block is stored in the second sub-area of the second area of the ferroelectric memory, and the new check code is used to replace the check code corresponding to the target data block stored in the third sub-area of the second area of the ferroelectric memory, and a write success flag is returned.
[0038] On the other hand, an embodiment of the present invention provides a data reading and writing device for a train automatic control system, characterized in that it includes:
[0039] A receiving module, used for receiving read and write instruction information for target data, wherein the read and write instruction information includes a target address in the ferroelectric memory corresponding to the target data;
[0040] A determination module, used to determine the number of the target data block corresponding to the target address in the ferroelectric memory according to the target address;
[0041] A read / write module, configured to perform read / write operations on the target data based on the serial number of the target data block;
[0042] In which, the ferroelectric memory is divided into two large areas, a first area and a second area, each large area is divided into at least three sub-areas, a first sub-area, a second sub-area and a third sub-area, and the data stored in each sub-area in the first area is exactly the same as the data stored in the corresponding sub-area in the second area, so that the first area and the second area back up each other, the first sub-area is used to store index identifiers, the second sub-area is used to store data blocks of a preset size, and the third sub-area is used to store check codes corresponding to the index identifiers and check codes corresponding to the data blocks.
[0043] On the other hand, an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0044] On the other hand, an embodiment of the present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0045] The train automatic control system data reading and writing method and device provided by the embodiment of the present invention adopts a partition and block verification method to verify and protect the data in the ferroelectric memory. While optimizing the fast and reliable reading and writing of data, it also realizes the redundant backup and automatic repair functions of the data, thereby improving the system performance and availability. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 A schematic diagram of a method for reading and writing data in a train automatic control system provided by an embodiment of the present invention;
[0047] Figure 2 A schematic diagram of a logical flow chart of data reading and writing of a train automatic control system provided by an embodiment of the present invention;
[0048] Figure 3 A schematic diagram of a data verification logic flow of a train automatic control system provided by an embodiment of the present invention;
[0049] Figure 4 A schematic diagram of a data reading and writing device for a train automatic control system provided by an embodiment of the present invention;
[0050] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0052] The on-board ATC equipment has high requirements for data security, and usually an additional cyclic redundancy check (CRC) code is saved in the data storage device to verify and protect all stored parameter data. However, when using EEPROM to store data, CRC verification protection is required for data. Whether reading or writing parameters, all parameters must be read out completely before CRC verification can be performed, which will seriously affect the reading and writing speed, and it is not possible to quickly read and write a certain parameter. In addition, if there are any errors in the saved parameters, all parameters will be in an untrustworthy state, affecting system availability.
[0053] Ferroelectric memory has a series of advantages such as long life, radiation resistance, high-speed random read and write, low power consumption, high reliability, and no data loss during power failure. It combines the dual advantages of RAM and ROM.
[0054] The embodiment of the present invention adopts ferroelectric memory to replace EEPROM, which can solve this problem well.
[0055] Figure 1 A schematic diagram of a method for reading and writing data in a train automatic control system provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, an embodiment of the present invention provides a method for reading and writing data of a train automatic control system, and the execution subject is the data reading and writing of the train automatic control system. The method includes:
[0056] Step S101: receiving read / write instruction information for target data, wherein the read / write instruction information includes a target address in a ferroelectric memory corresponding to the target data.
[0057] Specifically, an embodiment of the present invention adopts a ferroelectric memory as a storage medium for data of a train automatic control system. The ferroelectric memory is divided into two large areas, a first area and a second area. Each large area is divided into at least three sub-areas, a first sub-area and a third sub-area. The data stored in each sub-area in the first area is exactly the same as the data stored in the corresponding sub-area in the second area, so that the first area and the second area back up each other. The first sub-area is used to store index identifiers, the second sub-area is used to store data blocks of a preset size, and the third sub-area is used to store check codes corresponding to the index identifiers and check codes corresponding to the data blocks, for example, CRC check codes, etc.
[0058] Table 1 is the logical partition layout of the ferroelectric memory provided by the embodiment of the present invention, as shown in Table 1, Table 1 takes a ferroelectric memory with a capacity of 256KByte as an example for explanation, a ferroelectric memory with a capacity of 256kByte is divided into two large areas, the first area (area A) and the second area (area B), to realize the data redundancy storage function, and then each large area is divided into four sub-areas, the index identification area, the device parameter area, the key log area, and the CRC check area, wherein the CRC check area stores the CRC32 check codes of the three data areas of the index identification area, the device parameter area, and the key log area, and each 256Byte data in these three areas generates a CRC32 check code separately, and so on, a total of 504 check codes are generated and stored in the CRC check area in sequence, and each CRC32 check code occupies 4Byte space. The device parameter area and the key log area are used to store business data, wherein the device parameter area is used to store device parameters, and the key log area user stores the key log, and the business data in these two sub-areas are stored in the form of data blocks of preset sizes.
[0059] Table 1 is a logical partition layout of a ferroelectric memory provided by an embodiment of the present invention
[0060]
[0061] When a read / write operation is required for the target data, read / write instruction information for the target data is received, and the read / write instruction information includes a target address in the ferroelectric memory corresponding to the target data.
[0062] For example, when a read / write operation is performed on data data1, the address corresponding to data1 in the ferroelectric memory is 0000H, and the read / write instruction information for data1 includes the address 0000H.
[0063] Step S102: Determine the number of the target data block corresponding to the target address in the ferroelectric memory according to the target address.
[0064] Specifically, business data such as device parameters and key logs are stored in the second sub-area in the ferroelectric memory in the form of data blocks. A data block includes several bytes, for example, 256 bytes. Data is read and written in units of data blocks. If one byte in a data block needs to be read or written, the data block needs to be read and written as a whole.
[0065] Therefore, after the target address of the target data is determined, it is necessary to determine the number of the target data block corresponding to the target address in the ferroelectric memory according to the target address.
[0066] Step S103: Based on the number of the target data block, perform a read and write operation on the target data.
[0067] Specifically, after the serial number of the target data block is determined, a read and write operation on the target data is performed on the target data block.
[0068] If the target data is read, the target data block contains the target data, the target data block is read as a whole, and then the target data is extracted from the target data block.
[0069] If the write operation is for target data, the target data block is read out as a whole, and the target data is used to overwrite the data with the address of the target address in the target data block to obtain a new data block, and the new data block is written into the second sub-area of the ferroelectric memory to complete the write operation on the target data.
[0070] The train automatic control system data reading and writing method provided by the embodiment of the present invention adopts a partition and block verification method to verify and protect the data in the ferroelectric memory. While optimizing the fast and reliable reading and writing of data, it also realizes the redundant backup and automatic repair functions of the data, thereby improving the system performance and availability.
[0071] Based on any of the above embodiments, further, determining the number of the target data block corresponding to the target address in the ferroelectric memory according to the target address specifically includes:
[0072] Searching for an index identifier in a first sub-area of a first area of the ferroelectric memory to determine a serial number of the target data block;
[0073] The index identifier includes the starting address, the ending address and the serial number of each data block in the second sub-area, and the target address is between the starting address and the ending address of the target data block.
[0074] Specifically, after the target address of the target data is determined, it is necessary to determine the number of the target data block corresponding to the target address in the ferroelectric memory according to the target address.
[0075] The first sub-area of the ferroelectric memory is used to store an index identifier, which includes the starting address, ending address and number of each data block in the second sub-area. When determining the number of the target data block corresponding to the target address in the ferroelectric memory, the index identifier in the first sub-area of the first area of the ferroelectric memory is searched to determine the number of the target data block, and the target address is between the starting address and the ending address of the target data block.
[0076] If the target address is between the start address and the end address of a data block, then the determined target data block is one; if the target address is between the start address and the end address of multiple data blocks, then the determined target data blocks are multiple.
[0077] The train automatic control system data reading and writing method provided by the embodiment of the present invention adopts a partition and block verification method to verify and protect the data in the ferroelectric memory. While optimizing the fast and reliable reading and writing of data, it also realizes the redundant backup and automatic repair functions of the data, thereby improving the system performance and availability.
[0078] Based on any of the above embodiments, further, performing the read and write operations on the target data based on the number of the target data block specifically includes:
[0079] When a read operation is performed on the target data, the following steps are performed:
[0080] Reading the target data block from the second sub-area of the first area of the ferroelectric memory based on the number of the target data block, and reading a check code corresponding to the target data block from the third sub-area of the first area of the ferroelectric memory;
[0081] If the check code calculated based on the target data block currently read is the same as the check code currently read, the target data is extracted from the target data block currently read, and a read success flag is returned.
[0082] Specifically, Figure 2 A schematic diagram of a logic flow chart of data reading and writing of a train automatic control system provided by an embodiment of the present invention, such as Figure 2 As shown, when a read operation is performed on the target data, the first area ( Figure 2 The target data block is read from the second sub-area of the A area in the ferroelectric memory, and the check code corresponding to the target data block is read from the third sub-area of the first area of the ferroelectric memory.
[0083] Perform CRC check on the read data block.
[0084] If the check code calculated based on the currently read target data block is the same as the currently read check code, the target data is extracted from the currently read target data block, and a read success flag is returned.
[0085] The train automatic control system data reading and writing method provided by the embodiment of the present invention adopts a partition and block verification method to verify and protect the data in the ferroelectric memory. While optimizing the fast and reliable reading and writing of data, it also realizes the redundant backup and automatic repair functions of the data, thereby improving the system performance and availability.
[0086] Based on any of the above embodiments, further, performing the read and write operations on the target data based on the number of the target data block specifically includes:
[0087] When a read operation is performed on the target data, the following steps are performed:
[0088] Reading the target data block from the second sub-area of the first area of the ferroelectric memory based on the number of the target data block, and reading a check code corresponding to the target data block from the third sub-area of the first area of the ferroelectric memory;
[0089] If the check code calculated based on the target data block currently read is different from the check code currently read, the target data currently read and the check code currently read are discarded;
[0090] again reading the target data block from the second sub-area of the second area of the ferroelectric memory based on the number of the target data block, and reading a check code corresponding to the target data block from the third sub-area of the second area of the ferroelectric memory;
[0091] If the check code calculated based on the target data block currently read is the same as the check code currently read, the target data is extracted from the target data block currently read, and a read success flag is returned.
[0092] Specifically, if Figure 2 As shown, when a read operation is performed on the target data, the first area ( Figure 2 The target data block is read from the second sub-area of the A area in the ferroelectric memory, and the check code corresponding to the target data block is read from the third sub-area of the first area of the ferroelectric memory.
[0093] Perform CRC check on the read data block.
[0094] If the check code calculated based on the currently read target data block is different from the currently read check code, the currently read target data and the currently read check code are discarded, and the fault is processed and the fault cause code is returned.
[0095] Then, based on the number of the target data block, the second area ( Figure 2 The target data block is read from the second sub-area of the B area in the ferroelectric memory, and the check code corresponding to the target data block is read from the third sub-area of the second area of the ferroelectric memory.
[0096] The read data block is subjected to CRC check again.
[0097] If the check code calculated based on the currently read target data block is the same as the currently read check code, the target data is extracted from the currently read target data block, and a read success flag is returned.
[0098] In this case, the data block in the first area may be erroneous, so the target data block in the second area is backed up in the second area to ensure the possibility of data.
[0099] The train automatic control system data reading and writing method provided by the embodiment of the present invention adopts a partition and block verification method to verify and protect the data in the ferroelectric memory. While optimizing the fast and reliable reading and writing of data, it also realizes the redundant backup and automatic repair functions of the data, thereby improving the system performance and availability.
[0100] Based on any of the above embodiments, further, performing the read and write operations on the target data based on the number of the target data block specifically includes:
[0101] When a write operation is performed on the target data, the following steps are performed:
[0102] Reading the target data block from the second sub-area of the first area of the ferroelectric memory based on the number of the target data block, and reading a check code corresponding to the target data block from the third sub-area of the first area of the ferroelectric memory;
[0103] If the check code calculated based on the target data block currently read is the same as the check code currently read, the target data is written into the position of the target address in the target data block to obtain a new data block;
[0104] The target data is written into the ferroelectric memory based on a new data block.
[0105] Specifically, if Figure 2 As shown, when a write operation is performed on the target data, the first area ( Figure 2 The target data block is read from the second sub-area of the A area in the ferroelectric memory, and the check code corresponding to the target data block is read from the third sub-area of the first area of the ferroelectric memory.
[0106] Perform CRC check on the read data block.
[0107] If the checksum calculated based on the currently read target data block is different from the currently read checksum, the check fails, and the fault is handled and the fault cause code is returned. At this time, the target data block in the first area may be wrong, and the use mark of area B is obtained and the write operation is performed again.
[0108] If the check code calculated based on the currently read target data block is the same as the currently read check code, the target data is written to the position of the target address in the target data block to obtain a new data block, and the target data is written into the ferroelectric memory based on the new data block.
[0109] The train automatic control system data reading and writing method provided by the embodiment of the present invention adopts a partition and block verification method to verify and protect the data in the ferroelectric memory. While optimizing the fast and reliable reading and writing of data, it also realizes the redundant backup and automatic repair functions of the data, thereby improving the system performance and availability.
[0110] Based on any of the above embodiments, further, writing the target data into the ferroelectric memory based on the new data block specifically includes:
[0111] storing the new data block in the second sub-area of the first area and the second sub-area of the second area of the ferroelectric memory respectively;
[0112] Calculate a new checksum based on the new data block;
[0113] The check codes corresponding to the target data block stored in the third sub-area of the first area and the third sub-area of the second area of the ferroelectric memory are replaced with new check codes, and a write success flag is returned.
[0114] Specifically, when a write operation is performed on target data, the target data block is read from the second sub-area of the first area of the ferroelectric memory based on the number of the target data block, and the check code corresponding to the target data block is read from the third sub-area of the first area of the ferroelectric memory.
[0115] Perform CRC check on the read data block.
[0116] If the check code calculated based on the currently read target data block is the same as the currently read check code, the target data is written into the position of the target address in the target data block to obtain a new data block.
[0117] The new data block is stored in the second sub-area of the first area and the second sub-area of the second area of the ferroelectric memory respectively.
[0118] A new check code is calculated according to the new data block, and the check codes corresponding to the target data block stored in the third sub-area of the first area and the third sub-area of the second area of the ferroelectric memory are replaced with the new check code, and a write success flag is returned.
[0119] It should be noted that: in this embodiment, the new data block is stored first and the new check code is stored later. In actual application, it is not limited to this. The new check code can also be stored first and the new data block can be stored later, or both can be performed simultaneously.
[0120] The train automatic control system data reading and writing method provided by the embodiment of the present invention adopts a partition and block verification method to verify and protect the data in the ferroelectric memory. While optimizing the fast and reliable reading and writing of data, it also realizes the redundant backup and automatic repair functions of the data, thereby improving the system performance and availability.
[0121] Based on any of the above embodiments, further, writing the target data into the ferroelectric memory based on the new data block specifically includes:
[0122] Calculate a new checksum based on the new data block;
[0123] storing a new data block in the second sub-area of the first area of the ferroelectric memory, and replacing the check code corresponding to the target data block stored in the third sub-area of the first area of the ferroelectric memory with a new check code;
[0124] Reading the new data block from the second sub-area of the first area of the ferroelectric memory, and reading the new check code from the third sub-area of the first area of the ferroelectric memory;
[0125] If the check code calculated based on the new data block currently read is the same as the new check code currently read, the new data block is stored in the second sub-area of the second area of the ferroelectric memory, and the new check code is used to replace the check code corresponding to the target data block stored in the third sub-area of the second area of the ferroelectric memory, and a write success flag is returned.
[0126] Specifically, if Figure 2 As shown, when a write operation is performed on the target data, the first area ( Figure 2 The target data block is read from the second sub-area of the A area in the ferroelectric memory, and the check code corresponding to the target data block is read from the third sub-area of the first area of the ferroelectric memory.
[0127] Perform CRC check on the read data block.
[0128] If the check code calculated based on the currently read target data block is the same as the currently read check code, the target data is written into the position of the target address in the target data block to obtain a new data block.
[0129] In order to ensure the reliability of writing the target data into the ferroelectric memory based on the new data block, it is necessary to verify again:
[0130] First, a new checksum is calculated based on the new data block.
[0131] Then, the new data block is first stored in the second sub-area of the first area of the ferroelectric memory, and the new check code is used to replace the check code corresponding to the target data block stored in the third sub-area of the first area of the ferroelectric memory.
[0132] Then read the newly written data block from the second sub-area of the first area of the ferroelectric memory, and read the new check code from the third sub-area of the first area of the ferroelectric memory to perform data verification. If the verification fails, it is processed as a fault and the fault cause code is returned.
[0133] If the check code calculated based on the new data block currently read is the same as the new check code currently read, the index in the index identification area is updated, and the index is read back for index verification. If the verification fails, it is handled as a fault and the fault cause code is returned.
[0134] If the index check is also successful, the new data block is stored in the second sub-area of the second area of the ferroelectric memory, and the new check code is used to replace the check code corresponding to the target data block stored in the third sub-area of the second area of the ferroelectric memory, and a write success flag is returned.
[0135] The train automatic control system data reading and writing method provided by the embodiment of the present invention adopts a partition and block verification method to verify and protect the data in the ferroelectric memory. While optimizing the fast and reliable reading and writing of data, it also realizes the redundant backup and automatic repair functions of the data, thereby improving the system performance and availability.
[0136] Based on any of the above embodiments, when the train automatic control system program is started, all data in the ferroelectric memory can also be checked. Figure 3 A schematic diagram of a data verification logic flow of a train automatic control system provided by an embodiment of the present invention, such as Figure 3 As shown, the program first reads all the data in the first area (area A) and the second area (area B) in the ferroelectric memory into the memory, and then verifies the data in units of a preset size, for example, 256Byte. For example, the data can be verified by calculating the CRC check code and comparing it with the corresponding value in the CRC check area. If both areas A and B are verified correctly, the CRC data of areas A and B are verified again. If they are all the same, the data in area A-device parameter area is used to assign values to program variables. If there are different values, downtime protection is performed and fault recording is performed; if only area A is verified correctly, the data in area A-device parameter area is used to assign values to program variables, and all data in area A is copied to area B; if only area B is verified correctly, the data in area B-device parameter area is used to assign values to program variables, and all data in area B is copied to area A; if both areas AB are verified incorrectly, downtime protection is performed and fault recording is performed.
[0137] The method provided by the embodiment of the present invention has the following advantages:
[0138] The on-board ATC equipment uses ferroelectric memory instead of EEPROM to record key operating parameters and data, which can effectively shorten the system initialization time.
[0139] The data and key operation logs sent to the ATC at the moment of power failure can still be stably recorded.
[0140] Data block verification, when writing new data, only the data block (256Byte / block) where the data is located needs to be updated and read back and verified. Compared with the traditional full-chip readback verification method, it greatly saves data verification time, thereby reducing the time of the entire data writing process.
[0141] The data is stored in mirrored and redundant manner in areas AB, and the data in areas AB have self-checking function and bad area self-recovery function respectively, which greatly improves the security and availability of data.
[0142] By utilizing the high-speed read and write characteristics of ferroelectric memory, the key operation logs of the ATC system can be quickly recorded, effectively avoiding the problem of key operation logs being lost at the moment of power failure or downtime, and facilitating subsequent problem analysis and troubleshooting.
[0143] The following three specific scenarios are explained:
[0144] 1. A bit of data in area A of the ferroelectric memory is wrong.
[0145] During the ATC system's power-on self-test, it is found that the CRC check of a data block in area A fails, while the CRC check of the data blocks in area B are all correct. The correct data in area B is then used to overwrite the erroneous data in area A, and the operating parameter data stored in area B is returned to the ATC calling function, allowing the ATC to start running normally and simultaneously completing the self-repair of the erroneous data in area A.
[0146] 2. An error occurred when writing data to Tiedian during ATC operation, and the system restarted after downtime protection.
[0147] During the ATC operation, an error occurred when writing data to the iron electric, which caused downtime protection. After manual restart, when verifying the data in the AB area of the iron electric, it was found that one area was completely correct and the other area was wrong. Then the data of the area that was completely correct was used to run ATC, and the other area was automatically self-repaired.
[0148] 2. A fatal hardware failure caused the system to crash, and the relevant logs were not sent to the record board in time.
[0149] The writing speed of ferroelectric memory is comparable to that of RAM memory, and it can be saved when the power is off. At the moment of failure, the on-board capacitor and the time for the power supply voltage to drop are sufficient to record the fault log completely, which greatly facilitates the subsequent failure analysis.
[0150] Based on any of the above embodiments, Figure 4 A schematic diagram of a data reading and writing device for a train automatic control system provided by an embodiment of the present invention, such as Figure 4 As shown, an embodiment of the present invention provides a data reading and writing device for a train automatic control system, including a receiving module 401, a determining module 402 and a reading and writing module 403, wherein:
[0151] The receiving module 401 is used to receive read and write instruction information for target data, and the read and write instruction information includes a target address in the ferroelectric memory corresponding to the target data; the determining module 402 is used to determine the number of the target data block corresponding to the target address in the ferroelectric memory according to the target address; the reading and writing module 403 is used to perform read and write operations on the target data based on the number of the target data block; wherein the ferroelectric memory is divided into two large areas, a first area and a second area, each large area is divided into at least three sub-areas, a first sub-area, a second sub-area and a third sub-area, each sub-area in the first area stores exactly the same data as the corresponding sub-area in the second area, so that the first area and the second area back up each other, the first sub-area is used to store an index identifier, the second sub-area is used to store a data block of a preset size, and the third sub-area is used to store a check code corresponding to the index identifier and a check code corresponding to the data block.
[0152] The data reading and writing device for the train automatic control system provided in the embodiment of the present invention adopts a partitioned and block verification method to verify and protect the data in the ferroelectric memory. While optimizing the fast and reliable reading and writing of data, it also realizes the redundant backup and automatic repair functions of the data, thereby improving the system performance and availability.
[0153] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Figure 5 As shown, the electronic device includes: a processor (processor) 501, a communication interface (Communications Interface) 502, a memory (memory) 503 and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504. The processor 501 and the memory 502 communicate with each other through the bus 503. The processor 501 can call the logic instructions in the memory 503 to execute the following method:
[0154] Receiving read and write instruction information for target data, wherein the read and write instruction information includes a target address in the ferroelectric memory corresponding to the target data;
[0155] According to the target address, determining the number of the target data block corresponding to the target address in the ferroelectric memory;
[0156] Based on the serial number of the target data block, performing a read and write operation on the target data;
[0157] In which, the ferroelectric memory is divided into two large areas, a first area and a second area, each large area is divided into at least three sub-areas, a first sub-area, a second sub-area and a third sub-area, and the data stored in each sub-area in the first area is exactly the same as the data stored in the corresponding sub-area in the second area, so that the first area and the second area back up each other, the first sub-area is used to store index identifiers, the second sub-area is used to store data blocks of a preset size, and the third sub-area is used to store check codes corresponding to the index identifiers and check codes corresponding to the data blocks.
[0158] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0159] Furthermore, an embodiment of the present invention provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, and when the program instructions are executed by a computer, the computer can perform the steps in the above-mentioned method embodiments, for example, including:
[0160] Receiving read and write instruction information for target data, wherein the read and write instruction information includes a target address in the ferroelectric memory corresponding to the target data;
[0161] According to the target address, determining the number of the target data block corresponding to the target address in the ferroelectric memory;
[0162] Based on the serial number of the target data block, performing a read and write operation on the target data;
[0163] In which, the ferroelectric memory is divided into two large areas, a first area and a second area, each large area is divided into at least three sub-areas, a first sub-area, a second sub-area and a third sub-area, and the data stored in each sub-area in the first area is exactly the same as the data stored in the corresponding sub-area in the second area, so that the first area and the second area back up each other, the first sub-area is used to store index identifiers, the second sub-area is used to store data blocks of a preset size, and the third sub-area is used to store check codes corresponding to the index identifiers and check codes corresponding to the data blocks.
[0164] Furthermore, an embodiment of the present invention provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiments are implemented, for example, including:
[0165] Receiving read and write instruction information for target data, wherein the read and write instruction information includes a target address in the ferroelectric memory corresponding to the target data;
[0166] According to the target address, determining the number of the target data block corresponding to the target address in the ferroelectric memory;
[0167] Based on the serial number of the target data block, performing a read and write operation on the target data;
[0168] In which, the ferroelectric memory is divided into two large areas, a first area and a second area, each large area is divided into at least three sub-areas, a first sub-area, a second sub-area and a third sub-area, and the data stored in each sub-area in the first area is exactly the same as the data stored in the corresponding sub-area in the second area, so that the first area and the second area back up each other, the first sub-area is used to store index identifiers, the second sub-area is used to store data blocks of a preset size, and the third sub-area is used to store check codes corresponding to the index identifiers and check codes corresponding to the data blocks.
[0169] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0170] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0171] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for reading and writing data of a train automatic control system, characterized in that: include: Receiving read and write instruction information for target data, wherein the read and write instruction information includes a target address in the ferroelectric memory corresponding to the target data; According to the target address, determining the number of the target data block corresponding to the target address in the ferroelectric memory; Based on the serial number of the target data block, performing a read and write operation on the target data; The ferroelectric memory is divided into two large areas, a first area and a second area, each large area is divided into at least three sub-areas, a first sub-area, a second sub-area and a third sub-area, each sub-area in the first area stores data that is completely identical to the corresponding sub-area in the second area, so that the first area and the second area serve as backups for each other, the first sub-area is used to store an index identifier, the second sub-area is used to store a data block of a preset size, and the third sub-area is used to store a check code corresponding to the index identifier and a check code corresponding to the data block; The performing of the read and write operations on the target data based on the serial number of the target data block specifically includes: When a write operation is performed on the target data, the following steps are performed: Reading the target data block from the second sub-area of the first area of the ferroelectric memory based on the number of the target data block, and reading a check code corresponding to the target data block from the third sub-area of the first area of the ferroelectric memory; If the check code calculated based on the target data block currently read is the same as the check code currently read, the target data is written into the position of the target address in the target data block to obtain a new data block; Writing the target data into the ferroelectric memory based on the new data block; The step of writing the target data into the ferroelectric memory based on the new data block specifically includes: storing the new data block in the second sub-area of the first area and the second sub-area of the second area of the ferroelectric memory respectively; Calculate a new checksum based on the new data block; Replace the check codes corresponding to the target data block stored in the third sub-area of the first area and the third sub-area of the second area of the ferroelectric memory with a new check code, and return a write success flag; The step of writing the target data into the ferroelectric memory based on the new data block specifically includes: Calculate a new checksum based on the new data block; storing a new data block in the second sub-area of the first area of the ferroelectric memory, and replacing the check code corresponding to the target data block stored in the third sub-area of the first area of the ferroelectric memory with a new check code; Reading the new data block from the second sub-area of the first area of the ferroelectric memory, and reading the new check code from the third sub-area of the first area of the ferroelectric memory; Performing data verification based on a verification code calculated according to the new data block currently read and the new verification code read from the third sub-area of the first area of the ferroelectric memory; If the data verification is successful, the new data block is stored in the second sub-area of the second area of the ferroelectric memory, and the new verification code is used to replace the verification code corresponding to the target data block stored in the third sub-area of the second area of the ferroelectric memory, and a write success flag is returned; the writing of the target data into the ferroelectric memory based on the new data block also includes: If the data verification fails, it will be treated as a fault and the fault reason code will be returned; Before storing the new data block in the second sub-area of the second area of the ferroelectric memory, the method further comprises: If the data verification succeeds, the index identifier in the first sub-area of the first area is updated using the index identifier corresponding to the new data block currently read, and the index is read back to perform index verification to determine that the index verification is also successful; The step of writing the target data into the ferroelectric memory based on the new data block further comprises: If the data verification is successful, the index identifier corresponding to the new data block currently read is used to update the index identifier in the first sub-area of the first area, and the index is read back for index verification. If the index verification fails, it is processed as a fault and the fault cause code is returned.
2. The method for reading and writing data of a train automatic control system according to claim 1, characterized in that: The step of determining the number of the target data block corresponding to the target address in the ferroelectric memory according to the target address specifically includes: Searching for an index identifier in a first sub-area of a first area of the ferroelectric memory to determine a serial number of the target data block; The index identifier includes the start address, end address and number of each data block in the second sub-area, and the target address is between the start address and end address of the target data block.
3. The method for reading and writing data of a train automatic control system according to claim 1, characterized in that: The performing of the read and write operations on the target data based on the serial number of the target data block specifically includes: When a read operation is performed on the target data, the following steps are performed: Reading the target data block from the second sub-area of the first area of the ferroelectric memory based on the number of the target data block, and reading a check code corresponding to the target data block from the third sub-area of the first area of the ferroelectric memory; If the check code calculated based on the target data block currently read is the same as the check code currently read, the target data is extracted from the target data block currently read, and a read success flag is returned.
4. The method for reading and writing data of a train automatic control system according to claim 1, characterized in that: The performing of the read and write operations on the target data based on the serial number of the target data block specifically includes: When a read operation is performed on the target data, the following steps are performed: Reading the target data block from the second sub-area of the first area of the ferroelectric memory based on the number of the target data block, and reading a check code corresponding to the target data block from the third sub-area of the first area of the ferroelectric memory; If the check code calculated based on the target data block currently read is different from the check code currently read, the target data currently read and the check code currently read are discarded; again reading the target data block from the second sub-area of the second area of the ferroelectric memory based on the number of the target data block, and reading a check code corresponding to the target data block from the third sub-area of the second area of the ferroelectric memory; If the check code calculated based on the target data block currently read is the same as the check code currently read, the target data is extracted from the target data block currently read, and a read success flag is returned.
5. A data reading and writing device for a train automatic control system, characterized in that: include: A receiving module, used for receiving read and write instruction information for target data, wherein the read and write instruction information includes a target address in the ferroelectric memory corresponding to the target data; A determination module, used to determine the number of the target data block corresponding to the target address in the ferroelectric memory according to the target address; A read / write module, configured to perform read / write operations on the target data based on the serial number of the target data block; The ferroelectric memory is divided into two large areas, a first area and a second area, each large area is divided into at least three sub-areas, a first sub-area, a second sub-area and a third sub-area, each sub-area in the first area stores data that is completely identical to the corresponding sub-area in the second area, so that the first area and the second area serve as backups for each other, the first sub-area is used to store an index identifier, the second sub-area is used to store a data block of a preset size, and the third sub-area is used to store a check code corresponding to the index identifier and a check code corresponding to the data block; The performing of the read and write operations on the target data based on the serial number of the target data block specifically includes: When a write operation is performed on the target data, the following steps are performed: Reading the target data block from the second sub-area of the first area of the ferroelectric memory based on the number of the target data block, and reading a check code corresponding to the target data block from the third sub-area of the first area of the ferroelectric memory; If the check code calculated based on the target data block currently read is the same as the check code currently read, the target data is written into the position of the target address in the target data block to obtain a new data block; Writing the target data into the ferroelectric memory based on the new data block; The step of writing the target data into the ferroelectric memory based on the new data block specifically includes: storing the new data block in the second sub-area of the first area and the second sub-area of the second area of the ferroelectric memory respectively; Calculate a new checksum based on the new data block; Replace the check codes corresponding to the target data block stored in the third sub-area of the first area and the third sub-area of the second area of the ferroelectric memory with a new check code, and return a write success flag; The step of writing the target data into the ferroelectric memory based on the new data block specifically includes: Calculate a new checksum based on the new data block; storing a new data block in the second sub-area of the first area of the ferroelectric memory, and replacing the check code corresponding to the target data block stored in the third sub-area of the first area of the ferroelectric memory with a new check code; Reading the new data block from the second sub-area of the first area of the ferroelectric memory, and reading the new check code from the third sub-area of the first area of the ferroelectric memory; Performing data verification based on a verification code calculated according to the new data block currently read and the new verification code read from the third sub-area of the first area of the ferroelectric memory; If the data verification is successful, the new data block is stored in the second sub-area of the second area of the ferroelectric memory, and the verification code corresponding to the target data block stored in the third sub-area of the second area of the ferroelectric memory is replaced with the new verification code, and a write success flag is returned; The step of writing the target data into the ferroelectric memory based on the new data block further comprises: If the data verification fails, it will be treated as a fault and the fault reason code will be returned; Before storing the new data block in the second sub-area of the second area of the ferroelectric memory, the method further comprises: If the data verification succeeds, the index identifier in the first sub-area of the first area is updated using the index identifier corresponding to the new data block currently read, and the index is read back to perform index verification to determine that the index verification is also successful; The step of writing the target data into the ferroelectric memory based on the new data block further comprises: If the data verification is successful, the index identifier corresponding to the new data block currently read is used to update the index identifier in the first sub-area of the first area, and the index is read back for index verification. If the index verification fails, it is processed as a fault and the fault cause code is returned.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the train automatic control system data reading and writing method as described in any one of claims 1 to 4 are implemented.
7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for reading and writing data of a train automatic control system as claimed in any one of claims 1 to 4 are implemented.
