Disclosure of Invention
The invention mainly aims to provide a method for transmitting/scheduling data of an SD card, aiming at effectively controlling the acquisition and transmission of the data.
The invention provides a method for transmitting/scheduling data of an SD card, which comprises the following steps:
receiving data to be stored in an SD card;
data stream processing is carried out on data to be stored in the SD card, and the data is written into a memory buffer area;
dividing the data stream of the memory buffer area;
and transmitting the data stream subjected to the segmentation processing to an SD card for storage.
Preferably, the method for transmitting/scheduling SD card data in the real-time system further includes:
receiving a data reading instruction sent by external equipment;
according to the data reading instruction, carrying out segmentation processing on the data stream on the SD card;
transmitting the data stream subjected to the segmentation processing on the SD card to a memory buffer area;
and processing the data stream of the memory buffer area to form real-time system data for external equipment to obtain.
Preferably, the step of dividing the data stream of the memory buffer or dividing the data stream on the SD card specifically includes:
judging whether the time of data stream transmission exceeds the time allocated to the data stream transmission by the real-time system;
and if so, segmenting the data stream until the transmission time of the segmented data stream is lower than the time allocated by the real-time system for transmitting the data stream.
The invention also provides a device for transmitting/scheduling the data of the SD card, which comprises:
the data receiving module is used for receiving data to be stored in the SD card;
the data processing module is used for carrying out data stream processing on data to be stored in the SD card and writing the data into the memory buffer area; the data stream of the memory buffer area is also used for being divided;
and the data transmission module is used for transmitting the data stream subjected to the segmentation processing to the SD card for storage.
Preferably, the data transmission/scheduling apparatus further includes:
the instruction receiving module is used for receiving a data reading instruction sent by external equipment;
the data processing module is also used for carrying out segmentation processing on the data stream on the SD card according to the data reading instruction; the data processing device is also used for processing the data stream of the memory buffer area to form real-time system data for the external equipment to obtain;
the data transmission module is further configured to transmit the segmented data stream on the SD card to the memory buffer.
Preferably, the data processing module is specifically configured to:
judging whether the time of data stream transmission exceeds the time allocated to the data stream transmission by the real-time system;
and if so, segmenting the data stream until the transmission time of the segmented data stream is lower than the time allocated by the real-time system for transmitting the data stream.
The present invention also provides a data acquisition system, comprising:
the data monitoring device is used for monitoring the data of the real-time system according to preset configuration parameters and acquiring the data when the real-time system fails;
a data transmission/scheduling apparatus comprising:
the data receiving module is used for receiving the data collected by the data monitoring device;
the data processing module is used for carrying out data stream processing on the data acquired by the data monitoring device and writing the data into the memory buffer area; the data stream of the memory buffer area is also used for being divided;
and the data transmission module is used for transmitting the data stream subjected to the segmentation processing to the SD card for storage.
According to the invention, the data to be stored is transmitted to the SD card after being divided or the data to be read is read from the SD card after being divided according to the preset transmission strategy, so that the time for transmitting the data to the SD card or reading the data from the SD card does not occupy excessive system time resources, the correctness and the integrity of data transmission are ensured, and the problems of data storage and reading in a real-time system are effectively solved.
Detailed Description
The technical scheme of the invention is further explained by combining the drawings and the specific embodiments in the specification. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Fig. 1 is a flowchart illustrating an SD card data transmission/scheduling method according to an embodiment of the present invention.
Referring to fig. 1, the SD card data transmission/scheduling method of the present invention includes the following steps:
step S01, receiving data to be stored in the SD card;
when data in the real-time system is acquired by the data acquisition device, the data is generally stored, for example, in an SD card.
Step S02, processing data stream of data to be stored in SD card, and writing into memory buffer;
specifically, the data stream processing mainly includes: carrying out format conversion on data to be stored in an SD card to form a data stream with a uniform format, such as a 16-bit data stream; then splitting the data, and writing the split data into the buffer area of the memory in sequence. Of course, the data stream processing may further include: when writing into the buffer area of the memory, the data stream can be written according to the characteristics of the physical layer of the SD card according to the high 8 bits and the low 8 bits.
Step S03, performing segmentation processing on the data stream of the memory buffer;
and step S04, transmitting the data stream subjected to the segmentation processing to the SD card for storage.
Since in a real-time system the time slices occupied by each program are reasonably distributed. Thus, if any one program occupies too much system time resources, it may result in a system crash or an unresponsiveness to stimuli. Therefore, before storing the data in the memory buffer area in the SD card, the data stream in the buffer area needs to be divided according to the transmission policy, and then the divided data stream is transmitted to the SD card for storage. The transmission strategy is to control the program execution time of the data storage, and simultaneously ensure the correctness and the integrity of the data transmission.
Referring to fig. 2, the step S03 further includes:
step S031, judge whether the time of the data stream transmission exceeds the time that the real-time system transmits and distributes for the data stream; if yes, go to step S032; otherwise, executing step S04;
and estimating the transmission time of the data stream, and judging whether the transmission time of the data stream exceeds the time allocated to the data stream by a real-time system.
Step S032, dividing the data stream into a plurality of data streams, and returning to execute step S031;
if the time of the data stream transmission exceeds the time allocated to the data stream by the real-time system, the data stream of the long data frame is divided into a plurality of data streams of the short data frames until the time of the data stream transmission is lower than the time allocated to the data stream by the real-time system.
And if the data stream transmission time is judged to be lower than the time allocated to the data stream by the real-time system, sequentially transmitting the data stream to the SD card for storage.
According to the embodiment of the invention, the data to be stored in the SD card is firstly segmented and then transmitted to the SD card for storage according to the transmission strategy, so that the execution time of transmitting the data to the SD card is ensured not to occupy excessive system time resources, and the correctness and the integrity of data transmission are also ensured, thereby effectively solving the storage problem of the data in a real-time system.
Fig. 3 is a flowchart illustrating another embodiment of the SD card data transmission/scheduling method according to the present invention.
Referring to fig. 3, after step S04 of the above method embodiment, the method further includes:
step S05, receiving a data reading instruction sent by external equipment;
the data reading instruction can be generated by triggering when the real-time system fails. The data reading instruction can also be sent by a user through an external device, namely, the data reading instruction can be sent when the user needs to acquire real-time system data stored when a fault occurs. The data reading command may also be generated by automatically triggering the external device at intervals, for example, by presetting a timer and setting a time period, and then triggering the generation of the data reading command every other time period.
Step S06, according to the data reading instruction, the data stream on the SD card is divided;
step S07, transmitting the data flow after the segmentation processing on the SD card to a memory buffer area;
and reading the data stream on the physical layer of the SD card according to the data reading instruction, judging whether the transmission time of the data stream exceeds the time allocated to the data stream by a real-time system, if so, segmenting the data stream on the SD card to form a plurality of data streams of short data frames, and finally, transmitting the segmented data stream to a memory buffer area.
And step S08, processing the data stream of the memory buffer to form real-time system data for an external device to obtain.
Specifically, corresponding to the process of storing data into the SD card for data stream processing, data splicing processing is performed on the data stream transmitted from the SD card to the memory buffer area to form a 16-bit data stream, and format conversion is performed on the data stream in the buffer area to form real-time system data for external devices to obtain.
Referring to fig. 4, the step S06 further includes:
step S061, judging whether the time of data stream transmission exceeds the time allocated to the data stream transmission by the real-time system; if yes, executing step S062; otherwise, executing step S07;
step S062, divide dataflow into a plurality of dataflow, and return to and carry out step S061;
according to the embodiment of the invention, the data of the SD card is firstly segmented according to the transmission strategy, and then the segmented data of the SD card is read, so that the execution time for reading the data from the SD card is ensured not to occupy excessive system time resources, and the correctness and the integrity of data transmission are ensured, thereby effectively solving the problem of data storage in a real-time system.
Fig. 5 is a schematic structural diagram of an SD card data transmission/scheduling apparatus according to an embodiment of the present invention.
Referring to fig. 5, the SD card data transmission/scheduling apparatus of the present invention includes:
the data receiving module 10 is used for receiving data to be stored in the SD card;
the data processing module 20 is configured to perform data stream processing on data to be stored in the SD card, and write the data into a memory buffer; the data stream of the memory buffer area is also used for being divided;
and a data transmission module 30, configured to transmit the data stream subjected to the segmentation processing to an SD card for storage.
When the real-time system fails, the data acquisition device transmits the acquired data to the data receiving module 10. The data processing module 20 performs data stream processing on the acquired data received by the data receiving module 10, which specifically includes: carrying out format conversion on data to be stored in an SD card to form a data stream with a uniform format, such as a 16-bit data stream; then splitting the data, and writing the split data into the buffer area of the memory in sequence. Of course, the data stream processing may further include: when writing into the buffer area of the memory, the data stream can be written according to the characteristics of the physical layer of the SD card according to the high 8 bits and the low 8 bits. The data processing module 20 also divides the data stream in the memory buffer according to the transmission policy. The data transmission module 30 transmits the divided data stream to the SD card for storage. The transmission strategy is to control the program execution time of the data storage, and simultaneously ensure the correctness and the integrity of the data transmission. Specifically, the data processing module 20 may estimate the time for data stream transmission, and determine whether the time for data stream transmission exceeds the time allocated to data stream transmission by the real-time system; if so, dividing the data stream of the long data frame into a plurality of data streams of the short data frames, and until the transmission time of the divided data streams is lower than the time allocated for the data stream transmission by the real-time system; otherwise, no segmentation operation is performed. Finally, the data transmission module 30 transmits the data stream to the SD card for storage.
According to the embodiment of the invention, the data to be stored in the SD card is firstly segmented and then transmitted to the SD card for storage according to the transmission strategy, so that the execution time of transmitting the data to the SD card is ensured not to occupy excessive system time resources, and the correctness and the integrity of data transmission are also ensured, thereby effectively solving the storage problem of the data in a real-time system.
Fig. 6 is a schematic structural diagram of another embodiment of the SD card data transmission/scheduling apparatus according to the present invention.
Referring to fig. 6, on the basis of the above embodiment of the apparatus, the apparatus for transmitting/scheduling SD card data in a real-time system according to an embodiment of the present invention further includes:
an instruction receiving module 40, configured to receive a data reading instruction sent by an external device;
the data processing module 20 is configured to perform segmentation processing on a data stream on the SD card according to a data reading instruction; the data processing device is also used for processing the data stream of the memory buffer area to form real-time system data for the external equipment to obtain;
the data transmission module 30 is further configured to transmit the segmented data stream on the SD card to the memory buffer.
The data reading command received by the command receiving module 40 may be triggered and generated when the real-time system fails. The data reading instruction can also be sent by a user through an external device, namely, the data reading instruction can be sent when the user needs to acquire real-time system data stored when a fault occurs. The data reading command may also be generated by automatically triggering the external device at intervals, for example, by presetting a timer and setting a time period, and then triggering the generation of the data reading command every other time period. Then, the data processing module 20 may also divide the data stream on the SD card according to the data reading instruction, and then the data transmission module 30 transmits the divided data stream to the memory buffer. Finally, the data processing module 20 processes the data stream in the memory buffer to form real-time system data for the external device to obtain. Specifically, corresponding to the process of storing data into the SD card for data stream processing, data splicing processing is performed on the data stream transmitted to the memory buffer to form a 16-bit data stream, and finally format conversion is performed on the data stream in the buffer to form real-time system data.
It should be noted that, when the data processing module 20 performs the segmentation processing on the data stream on the SD card, it may be determined whether the time for transmitting the data stream exceeds the time allocated to the data stream by the real-time system, and if so, the data stream on the SD card is segmented to form a data stream of a plurality of short data frames; otherwise, no segmentation operation is performed.
According to the embodiment of the invention, the data of the SD card is firstly segmented according to the transmission strategy, and then the segmented data of the SD card is read, so that the execution time for reading the data from the SD card is ensured not to occupy excessive system time resources, and the correctness and the integrity of data transmission are ensured, thereby effectively solving the problem of data storage in a real-time system.
FIG. 7 is a schematic diagram of an embodiment of a data acquisition system according to the present invention.
Referring to fig. 6, the data acquisition system of the present invention includes a data monitoring apparatus 100 and a data transmission/scheduling apparatus 200. Wherein,
the data monitoring device 100 is used for monitoring the data of the real-time system according to preset configuration parameters and acquiring the data when the real-time system fails;
real-time systems such as wind energy converter systems have a large amount of waveform data acquisition, so that the systems can be debugged or analyzed for faults in time according to the acquired data by acquiring the data of the systems. The real-time system can acquire data through an AD acquisition device, an FPGA acquisition device and the like. The AD collector is mainly used for collecting analog signals of all components in a real-time system and converting the analog signals into data signals; the FPGA collector is mainly used for collecting switching value signals of all components in a real-time system, such as pulse signals generated by faults of a certain component.
The preset configuration parameters according to which the data monitoring device 100 may be default configuration parameters when the real-time system performs data acquisition, for example, fault monitoring parameters commonly used in the wind energy converter, that is, a-phase, B-phase, and C-phase voltages of the power grid, a-phase, B-phase, and C-phase currents output by the inverter, and the like. The preset configuration parameters may also be parameters specifically configured according to specific situations when data acquisition is performed in the real-time system, for example, specific data of a certain component needs to be acquired in the real-time system. Therefore, the data monitoring device 100 monitors the data of the real-time system according to the preset configuration parameters, receives the data collected by the AD collector and the FPGA collector, stores the data in the memory, and stores the monitored data in the SD card when the real-time system fails. Specifically, if the preset configuration parameter is to acquire specific data of a certain component in the real-time system, not only the commonly used fault monitoring data is monitored, but also the data of the component acquired in the real-time system is monitored.
Referring to fig. 5 again, the data transmission/scheduling apparatus 200 may include:
the data receiving module 10 is used for receiving data collected by the data monitoring device;
the data processing module 20 is configured to perform data stream processing on the data acquired by the data monitoring device, and write the data into a memory buffer; the memory buffer area is used for storing the data stream of the memory buffer area;
and a data transmission module 30, configured to transmit the data stream subjected to the segmentation processing to an SD card for storage.
When the real-time system fails, the data acquisition device transmits the acquired data to the data receiving module 10. The data processing module 20 performs data stream processing on the acquired data received by the data receiving module 10, which specifically includes: carrying out format conversion on data to be stored in an SD card to form a data stream with a uniform format, such as a 16-bit data stream; then splitting the data, and writing the split data into the buffer area of the memory in sequence. Of course, the data stream processing may further include: when writing into the buffer area of the memory, the data stream can be written according to the characteristics of the physical layer of the SD card according to the high 8 bits and the low 8 bits. The data processing module 20 further divides the data stream in the memory buffer according to the transmission policy, and the data transmission module 30 transmits the divided data to the SD card for storage. The transmission strategy is to control the program execution time of the data storage, and simultaneously ensure the correctness and the integrity of the data transmission.
When the data processing module 20 performs the segmentation processing on the data stream of the memory buffer, it may first estimate the time for transmitting the data stream, and determine whether the time for transmitting the data stream exceeds the time allocated to transmit the data stream by the real-time system; if so, dividing the data stream of the memory buffer area, dividing the data stream of the long data frame into a plurality of data streams of the short data frames until the transmission time of the divided data streams is lower than the time allocated for the data stream transmission by the real-time system; otherwise, no segmentation is performed.
According to the embodiment of the invention, the data to be stored in the SD card is firstly segmented and then transmitted to the SD card for storage according to the transmission strategy, so that the execution time of transmitting the data to the SD card is ensured not to occupy excessive system time resources, and the correctness and the integrity of data transmission are also ensured, thereby effectively solving the storage problem of the data in a real-time system.
Referring to fig. 6 again, the data transmission/scheduling apparatus 200 may further include:
an instruction receiving module 40, configured to receive a data reading instruction sent by an external device;
the data processing module 20 is further configured to perform segmentation processing on the data stream on the SD card according to the data reading instruction; the data processing device is also used for processing the data stream of the memory buffer area to form real-time system data for the external equipment to obtain;
the data transmission module 30 is further configured to transmit the segmented data stream on the SD card to the memory buffer.
The data reading command received by the command receiving module 40 may be triggered and generated when the real-time system fails. The data reading instruction can also be sent by a user through an external device, namely, the data reading instruction can be sent when the user needs to acquire real-time system data stored when a fault occurs. The data reading command may also be generated by automatically triggering the external device at intervals, for example, by presetting a timer and setting a time period, and then triggering the generation of the data reading command every other time period. Then, the data processing module 20 further divides the data stream on the SD card according to the data reading instruction, and then the data transmission module 30 transmits the divided data stream to the memory buffer. Finally, the data processing module 20 processes the data stream in the memory buffer to form real-time system data for the external device to obtain. Specifically, corresponding to the process of storing data into the SD card for data stream processing, data splicing processing is performed on the data stream transmitted to the memory buffer to form a 16-bit data stream, and finally format conversion is performed on the data stream in the buffer to form real-time system data.
It should be noted that, when the data processing module 20 performs the segmentation processing on the data stream, it may be determined whether the time for transmitting the data stream exceeds the time allocated to the data stream by the real-time system, and if so, the data stream on the SD card is segmented to form a data stream of a plurality of short data frames; otherwise, no segmentation operation is performed.
According to the embodiment of the invention, the data of the SD card is firstly segmented according to the transmission strategy, and then the segmented data of the SD card is read, so that the execution time for reading the data from the SD card is ensured not to occupy excessive system time resources, and the correctness and the integrity of data transmission are ensured, thereby effectively solving the problem of data storage in a real-time system.
The above description is only for the preferred embodiment of the present invention and is not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes that can be directly or indirectly applied to other related technical fields using the contents of the present specification and the accompanying drawings are included in the scope of the present invention.