WO2013056420A1 - 搅拌站以及用于该搅拌站的数据存储方法、服务器、系统 - Google Patents

搅拌站以及用于该搅拌站的数据存储方法、服务器、系统 Download PDF

Info

Publication number
WO2013056420A1
WO2013056420A1 PCT/CN2011/080926 CN2011080926W WO2013056420A1 WO 2013056420 A1 WO2013056420 A1 WO 2013056420A1 CN 2011080926 W CN2011080926 W CN 2011080926W WO 2013056420 A1 WO2013056420 A1 WO 2013056420A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
buffer
time period
database
time
Prior art date
Application number
PCT/CN2011/080926
Other languages
English (en)
French (fr)
Inventor
车通
殷岳元
陈兵
Original Assignee
中联重科股份有限公司
湖南中联重科专用车有限责任公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中联重科股份有限公司, 湖南中联重科专用车有限责任公司 filed Critical 中联重科股份有限公司
Priority to PCT/CN2011/080926 priority Critical patent/WO2013056420A1/zh
Publication of WO2013056420A1 publication Critical patent/WO2013056420A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/46Caching storage objects of specific type in disk cache
    • G06F2212/465Structured object, e.g. database record

Definitions

  • the present invention relates to the field of data storage, and in particular to a mixing station and a data storage method, server, and system for the same. Background technique
  • Existing data servers mostly use blocking mode to store data. Specifically, after the data server receives the data, the data server stores the data in the buffer area, and then stores the data in the buffer into the database, and the data is stored in the data. After storing in the database, the next data is received.
  • the present invention occupies very few CPU time slices, has fast buffer resource release, and has high execution efficiency.
  • the present invention provides a data storage method for a mixing station communication server, the method comprising: receiving data in a first time period, and writing data received in the time period into a plurality of buffers a first buffer; and receiving data in the second time period, and writing the data received in the time period to the second buffer in the plurality of buffers, and writing the data in the previous time period
  • the data in the buffer is stored in the database.
  • the present invention also provides a mixing station communication server, the server comprising: a data receiving device for receiving data; a storage device comprising a plurality of buffers; and a processor coupled to the data receiving device and the storage device , for: in the first time period, the data is connected The data received by the receiving device during the time period is written into the first buffer in the plurality of buffers; and in the second time period, the data received by the data receiving device during the time period is written into the plurality of The second buffer in the buffer stores the data in the buffer in which the previous period has been written into the database.
  • the present invention also provides a mixing station system, the system comprising: an in-vehicle terminal for transmitting data; and the above-described mixing station communication server.
  • the present invention also provides a mixing station comprising the above-described mixing station communication server.
  • data can be written into a buffer, and if the data is not stored in the database, the next data is received, and the data is stored in another buffer, and at the same time
  • the buffer of the data reads the data and stores it in the database.
  • the I/O operation of storing the data into the database can be performed independently by a thread, and the receiving of the data does not need to wait for other work.
  • the data can be continuously received, and at the same time, the previously received data is continuously stored in the database, and the execution efficiency is high, and the CPU time is small.
  • Figure 1 is a schematic structural view of a mixing station system
  • FIG. 2A is a flowchart of a data storage method according to a first embodiment of the present invention.
  • FIGS. 3A-3C are flowcharts of a data storage method according to a first embodiment of the present invention.
  • 4A is a second embodiment of the present invention
  • Figure 4B is a second embodiment of the present invention:
  • the data server 100 receives data from the in-vehicle terminal 300 via the communication server 200, and stores the data in a database for scheduling by the dispatching center 400.
  • the present invention provides a data storage method for a mixing station communication server, the method comprising: receiving data during a first time period, and writing data received during the time period to a first buffer in a plurality of buffers And receiving data in the second time period, and writing the data received in the time period to the second buffer in the plurality of buffers, and writing the previous time period into the buffer of the data
  • the data is stored in the database. Thereby, data can be written into a buffer, and if the data is not stored in the database, the next data is received, and the data is stored in another buffer, and at the same time, data is written.
  • the buffer reads the data and stores it in the database.
  • the I/O operation of storing the data into the database can be performed independently by a thread, and the receiving of the data does not need to wait for other work. Can continuously receive data, and at the same time continue to receive the previous The data is stored in the database, and the execution efficiency is high, and the CPU time is small.
  • the method may further include: writing, during the third time period, data required to be stored in the time period to the third buffer or the third buffer of the plurality of buffers, before reading the time The data in the buffer in which data has been written in the segment is stored in the database. At this time, for writing to the first buffer, the data stored in the first buffer can be directly covered.
  • the buffer is released.
  • the effect of dynamically releasing the buffer is obtained, so that the buffer that is released can be used for other applications, and the buffer is prevented from being occupied for a long time.
  • the steps for the second time period and the third time period may be performed alternately cyclically.
  • the method may further include: establishing a read/write flag, switching the value of the read/write flag between the first value and the second value every preset time, where the step and the second time period are The step for the third time period alternates when the value of the read/write flag is switched.
  • FIG. 2A is a flowchart of a data storage method according to a first embodiment of the present invention.
  • the present invention provides an asynchronous data storage method, the method comprising: pre-creating a first memory management list and a second memory management list; and storing the time period in the first time period Data is written into the memory, and the memory address is added to the first memory management list; and in the second time period, data required to be stored in the time period is written into the memory, and the memory address is added to the second
  • the memory management list reads the data stored in the memory address in the first memory management list at the same time, and stores the data in the database, and then deletes the memory address in the first memory management list.
  • the method further includes: writing, during the third time period, data required to be stored in the time period to the memory, and adding the memory address to the first memory management list, and simultaneously reading the second memory management The data stored in the memory address in the list, and the data is stored in the database, The memory address in the second memory management list is then deleted.
  • the durations of the first time period, the second time period, and the third time period may be set according to the capacity of the memory and the amount of data to be stored in each time period, so that the memory can accommodate the corresponding time period. All the data you need to store. For example, the larger the capacity of the memory, the longer the duration of the time period needs to be set; the larger the amount of data to be stored in a period of time, the shorter the duration of the time period needs to be set, so that the memory can be The storage of data for this time period is satisfied.
  • the memory corresponding to the memory address may be released after the data stored in the memory address in the first memory management list or the second memory management list is stored in the database. In this way, the memory resources can be released in time, so that the released resources can be used for subsequent storage of the required data or for other purposes, realizing the dynamic allocation and release of memory.
  • the steps for the second time period and the third time period may be cyclically performed alternately, that is, the memory address for writing data is managed by the first memory management list for a period of time, and at the same time, the reading is performed.
  • the second memory management list stores the data stored in the memory address, and stores the data in the database; in another period of time, the memory address for writing the data is managed by the second memory management list, where At the same time, the data stored in the memory address included in the first memory management list is read, and the data is stored in the database; after that, the memory address for writing the data is managed by the first memory management list, and at the same time , reading the data stored in the memory address included in the second memory management list, and storing the data in the database.
  • the functions of the first memory management list and the second memory management list can be continuously rotated (that is, used for writing data and reading data, respectively), and a large amount of continuous data is stored, and the execution efficiency is high.
  • the method further includes: establishing a read/write flag, the read/write flag is switched between the first value (for example, 1) and the second value (for example, 2) every preset time (for example, 10 seconds), The switching between the first time period, the second time period, and the third time period is performed according to the change of the read/write flag.
  • the specific use of the read and write flag will be described in detail below in conjunction with Figures 3A-3C.
  • the switching between the first time period, the second time period and the third time period does not have to be implemented by means of the read/write flag, and other switching conditions can be set in the program (for example, This is achieved when the data stored in the memory reaches the upper limit of the capacity.
  • FIG. 2B is a schematic diagram of an execution process of a data storage method according to a first embodiment of the present invention.
  • the memory addresses managed by the first and second memory management lists are fixed, corresponding to the buffer A and the buffer B in the memory, respectively, for convenience of explanation.
  • both buffer A and buffer B are empty.
  • the data transmitted by the network terminal 310 is written to the buffer A.
  • the data transmitted by the network terminal 310 is written to the buffer B, the data stored in the buffer A is simultaneously read, and the data is written into the database 110, after which the buffer A is released.
  • the data transmitted by the network terminal 310 is written to the buffer A, the data stored in the buffer B is simultaneously read, and the data is written into the database 110, after which the buffer B is released.
  • the data sent by the network terminal 310 is written into the buffer B, the data stored in the buffer A is read at the same time, and the data is written into the database 110, and then the buffer A is released (the time period)
  • the operation performed by t3 is the same as the operation performed in the above period t3).
  • the cycle alternately performs the same operations as those performed in the above-described time periods t3 and t4 until the time period tn. Thereby, the operation of continuously writing and reading a large number of continuously required data to be stored in the database 110 is performed, and the data storage efficiency is improved.
  • FIGS. 3A-3C are diagrams showing the above-described asynchronous data storage method of the first embodiment of the present invention, taking the stirring station system shown in Fig. 1A as an example. A specific embodiment of the data storage method of the present invention will be described below with reference to Figs. 3A-3C.
  • the asynchronous data storage is executed by two threads, that is, a main thread and a data storage thread, wherein the data storage thread is created by the main thread, and the main thread creates the data storage thread while creating the read and write.
  • Flag, first memory management list, and second memory management list FIG. 3A shows an operation flow of the main thread (the operation of creating a data storage thread and creating a read/write flag, a first memory management list, and a second memory management list is omitted here), as shown in FIG.
  • the data server 100 The main thread starts the communication function of the data server 100, waits for the data, and after parsing the data from the in-vehicle terminal 300, parses the data, and if the data is valid data, sends the data to the data storage thread. And in the data server 100 The data is displayed on the graphical interface; in the event that the data is invalid, the data is discarded. Thereafter, the main thread determines whether to exit the communication, and if so, turns off the communication function, and if not, proceeds to the step of waiting for the data. The determining whether the data is valid data may be verified by a check code included in the data, and the check may be, for example, a parity check, a HASH check, or an MD5 check.
  • Fig. 3B shows the operation flow of the write buffer of the data storage thread
  • Fig. 3C shows the operation flow of the data storage thread's read buffer and stored in the database
  • Fig. 3B operates in parallel with the operation shown in Fig. 3C.
  • the data storage thread receives data from the main thread, writes the data into the memory, and determines the read/write flag.
  • the read/write flag is 1, the written memory address is added to the first memory management. List; when the read/write flag is 2, the written memory address is added to the second memory management list.
  • the data storage thread performs an operation of storing data stored in the memory address in the first or second memory management list into the database every predetermined time, and at the same time, switching the first memory management.
  • the data storage thread determines whether the database is connected.
  • the operation of connecting to the database is performed; when the database is connected, the read/write flag is judged, and when the read/write flag is 1, the read/write flag is set to 2, Reading the data stored in the memory address in the first memory management list, storing the data in the database, and releasing the memory corresponding to the memory address, deleting the memory address from the first memory management list; 2, the read and write flag is set to 1, the data stored in the memory address in the second memory management list is read, the data is stored in the database, and the memory corresponding to the memory address is released, from the second memory management list Delete the memory address in .
  • the read/write flag when determining the read/write flag, assuming that the read/write flag is 1, the read/write flag is set to 2, and the data stored in the memory address in the first memory management list is read, and the data is read.
  • the data is stored in the database, and the memory corresponding to the memory address is released.
  • the memory address is deleted from the first memory management list, and then the data storage thread enters a waiting period, and after waiting for a predetermined time, the above operation is performed again.
  • the read/write flag is 2
  • the data stored in the memory address in the second memory management list is read, the data is stored in the database, and the memory corresponding to the memory address is released, from the second memory management list. Delete the memory address.
  • the data storage thread adds the memory address to which the received data is written to the first memory management list.
  • the read/write flag sets the read/write flag to 2 (the memory address to which the received data is written will be added to the second memory management). List)
  • reading the data stored in the memory address in the first memory management list storing the data in the database, and releasing the memory corresponding to the memory address, and deleting the memory address from the first memory management list.
  • the data storage method of the second embodiment of the present invention includes: creating a buffer, a read pointer, and a write pointer, the read pointer and the write pointer are located at the buffer header; and by moving the write pointer, The data to be stored is written to the buffer while the data written in the buffer is read by moving the read pointer, and the data is stored in the database. Thereby, the data can be written by the write pointer, and the data can be read and stored in the database by using the read pointer at the same time, and the asynchronous storage of the data can be realized.
  • the continuous reception of data is realized, and it is not necessary to receive the next data after the data is stored in the database, and the execution efficiency is high, and the CPU time is small.
  • the read pointer and the write pointer move to the end of the buffer, the read pointer and the write pointer return to the buffer header. In this way, the buffer can be recycled if the buffer is full.
  • FIG. 4B is a schematic diagram of an execution process of the data storage method shown in FIG. 4A. As shown in Fig. 4B, the left drawing shows the case where the buffer is not full, and the right drawing shows the case where the buffer has been filled and the write pointer is returned to the buffer head.
  • the present invention also provides a mixing station communication server, the server comprising: a data receiving device for receiving data; a storage device comprising a plurality of buffers; and a processor coupled to the data receiving device and the storage device For: in a first time period, writing data received by the data receiving device in the time period to a first buffer in a plurality of buffers; and in a second time period, the data receiving device The data received during the time period is written into the second buffer in the plurality of buffers, and the data in the buffer in which the data has been written in the previous period is stored in the database.
  • the processor may be further configured to write data received in the time period to the third buffer or the third buffer in the multiple buffers in a third time period, and the previous time period
  • the data in the buffer in which the data has been written is stored in the database.
  • the processor may be further configured to release the buffer after storing data in a buffer in which data has been written in a previous period of time into the database.
  • the processor may alternately perform the step loop for the second time period and the third time period.
  • the present invention also provides a mixing station system, the system comprising: an in-vehicle terminal for transmitting data; and the above-described mixing station communication server.
  • the present invention also provides a mixing station comprising the above mixing station communication service Server.
  • mixing station communication server the mixing station system, and the mixing station are the same as those described above for the mixing station communication server, and are not described herein.
  • data can be written into a buffer, and if the data is not stored in the database, the next data is received, and the data is stored in another buffer, and at the same time
  • the buffer of the data reads the data and stores it in the database.
  • the I/O operation of storing the data into the database can be performed independently by a thread, and the receiving of the data does not need to wait for other work.
  • the data can be continuously received, and at the same time, the previously received data is continuously stored in the database, the execution efficiency is high, the CPU time is small, and the dynamic allocation and release of the buffer are realized.
  • Applying the present invention to a mixing station system can significantly improve data reception and storage speed from an in-vehicle terminal, and solve problems in a situation in which network conditions are poor and a large number of in-vehicle terminals are concurrent.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明公开了一种搅拌站以及用于该搅拌站的数据存储方法、服务器、系统,所述方法包括:在第一时间段,接收数据,并将该时间段所接收的数据写入多个缓冲区中的第一缓冲区;以及在第二时间段,接收数据,并将该时间段所接收的数据写入所述多个缓冲区中的第二缓冲区,将之前的时间段已写入数据的缓冲区内的数据存入数据库。本发明与需在数据存入数据库之后方才能够接收下一数据的阻塞存储模式相比,将数据存入数据库这种I/O操作可由一线程独立执行,数据的接收不需要等待其他工作,从而可不断接收数据,并于此同时不断将之前所接收的数据存入数据库内,执行效率高,占用CPU时间片少。

Description

搅拌站以及用于该搅拌站的数据存储方法、 服务器、 系统 技术领域
本发明涉及数据存储领域, 具体地, 涉及一种搅拌站以及用于该搅拌 站的数据存储方法、 服务器、 系统。 背景技术
现有的数据服务器多采用阻塞模式来存储数据, 其具体为数据服务器 在收到数据之后, 将该数据存入缓存区内, 之后再将该缓冲区内的数据存 入数据库内, 并在数据存入数据库之后, 方才接收下一数据。
然而, 将数据存储至数据库是一个比较消耗资源及时间的操作, 尤其 是在数据量较大的情况下, 该操作会导致大量 CPU时间片被占用, 且缓冲 区资源释放缓慢, 严重阻塞了新到达数据服务器的数据的存储。 发明内容
本发明的目的是提供一种搅拌站以及用于该搅拌站的数据存储方法、 服务器、 系统, 本发明占用非常少的 CPU时间片, 缓冲区资源释放快, 执 行效率高。
为了实现上述目的, 本发明提供一种用于搅拌站通信服务器的数据存 储方法, 该方法包括: 在第一时间段, 接收数据, 并将该时间段所接收的 数据写入多个缓冲区中的第一缓冲区; 以及在第二时间段, 接收数据, 并 将该时间段所接收的数据写入所述多个缓冲区中的第二缓冲区, 将之前的 时间段已写入数据的缓冲区内的数据存入数据库。
相应地, 本发明还提供一种搅拌站通信服务器, 该服务器包括: 数据 接收装置, 用于接收数据; 存储装置, 包含多个缓冲区; 以及处理器, 与 所述数据接收装置和存储装置相连, 用于: 在第一时间段, 将所述数据接 收装置于该时间段所接收的数据写入多个缓冲区内的第一缓冲区; 以及在 第二时间段, 将所述数据接收装置于该时间段所接收的数据写入所述多个 缓冲区内的第二缓冲区, 将之前的时间段已写入数据的缓冲区内的数据存 入数据库。
相应地, 本发明还提供一种搅拌站系统, 该系统包括: 车载终端, 用 于发送数据; 以及上述搅拌站通信服务器。
相应地, 本发明还提供一种搅拌站, 该搅拌站包括上述搅拌站通信服 务器。
通过上述技术方案, 可向一缓冲区内写入数据, 并在该数据未被存入 数据库的情况下, 接收下一数据, 并将该数据存入另一缓冲区, 与此同时 从写有数据的缓冲区读取数据并将该数据存入数据库内。 该过程与需在数 据存入数据库之后方才能够接收下一数据的阻塞存储模式相比, 将数据存 入数据库这种 I/O操作可由一线程独立执行,数据的接收不需要等待其他工 作, 从而可不断接收数据, 并于此同时不断将之前所接收的数据存入数据 库内, 执行效率高, 占用 CPU时间片少。
本发明的其他特征和优点将在随后的具体实施方式部分予以详细说 明。 附图说明
附图是用来提供对本发明的进一步理解, 并且构成说明书的一部分, 与下面的具体实施方式一起用于解释本发明, 但并不构成对本发明的限制。 在附图中:
图 1为搅拌站系统的结构示意图;
图 2A为本发明第一实施方式的数据存储方法的流程图;
图 2B为本发明第一实施方式的数据存储方法的执行过程示意图; 图 3A-3C为本发明第一实施方式的数据存储方法的流程图; 图 4A为本发明第二
图 4B为本发明第二: 附图标记说明
100 数据服务器 200 通信服务器 300 车载终端 400 调度中心
A、 B、 C 缓冲区 P1 写指针
P2 读指针 具体实施方式
以下结合附图对本发明的具体实施方式进行详细说明。应当理解的是, 此处所描述的具体实施方式仅用于说明和解释本发明, 并不用于限制本发 明。
如图 1所示, 在搅拌站运营管理过程中, 数据服务器 100需经由通信 服务器 200接收来自车载终端 300的数据, 并将该数据存储于数据库内, 以供调度中心 400进行调度。
本发明提供了一种用于搅拌站通信服务器的数据存储方法, 该方法包 括: 在第一时间段, 接收数据, 并将该时间段所接收的数据写入多个缓冲 区中的第一缓冲区; 以及在第二时间段, 接收数据, 并将该时间段所接收 的数据写入所述多个缓冲区中的第二缓冲区, 将之前的时间段已写入数据 的缓冲区内的数据存入数据库。 籍此, 可向一缓冲区内写入数据, 并在该 数据未被存入数据库的情况下, 接收下一数据, 并将该数据存入另一缓冲 区, 与此同时从写有数据的缓冲区读取数据并将该数据存入数据库内。 该 过程与需在数据存入数据库之后方才能够接收下一数据的阻塞存储模式相 比,将数据存入数据库这种 I/O操作可由一线程独立执行,数据的接收不需 要等待其他工作, 从而可不断接收数据, 并于此同时不断将之前所接收的 数据存入数据库内, 执行效率高, 占用 CPU时间片少。
其中, 该方法还可包括: 在第三时间段, 将该时间段所需存储的数据 写入所述第一缓冲区或所述多个缓冲区中的第三缓冲区, 读取之前的时间 段内已写入数据的缓冲区内的数据存入数据库。 此时, 对于写入所述第一 缓冲区而言, 可直接覆盖第一缓冲区内存入的数据。
其中, 在将所述之前的时间段已写入数据的缓冲区内的数据存入所述 数据库之后, 释放该缓冲区。 籍此, 得到动态释放缓冲区的效果, 使得被 释放的缓冲区可用于其他应用, 避免该缓冲区被长期占用。
其中, 所述针对第二时间段和第三时间段的步骤可循环交替执行。 其中, 该方法还可包括: 建立一读写标志, 每隔预设时间将该读写标 志的值于第一值与第二值之间切换一次, 所述针对第二时间段的步骤与所 述针对第三时间段的步骤在该读写标志的值切换时进行交替。
以下结合具体实施方式来对本发明提供的异步数据存储方法进行描 述。
第一实施方式
图 2A为本发明第一实施方式的数据存储方法的流程图。如图 2A所示, 本发明提供了一种异步数据存储方法, 该方法包括: 预先创建第一内存管 理列表和第二内存管理列表; 在第一时间段内, 将该时间段所需存储的数 据写入内存, 并将该内存地址加入所述第一内存管理列表; 以及在第二时 间段内, 将该时间段所需存储的数据写入内存, 并将该内存地址加入所述 第二内存管理列表, 同时读取所述第一内存管理列表内的内存地址所存储 的数据, 并将该数据存入数据库, 之后删除所述第一内存管理列表内的内 存地址。
其中, 该方法还包括: 在第三时间段内, 将该时间段所需存储的数据 写入内存, 并将该内存地址加入所述第一内存管理列表, 同时读取所述第 二内存管理列表内的内存地址所存储的数据, 并将该数据存入所述数据库, 之后删除所述第二内存管理列表内的内存地址。
其中, 所述第一时间段、 第二时间段以及第三时间段的持续时间可根 据所述内存的容量以及各时间段所需存储的数据的量而设置, 以使得内存 可容纳相应时间段所需存储的所有数据。 例如, 内存的容量越大, 则时间 段的持续时间需设置得越长; 一时间段所需存储的数据的量越大, 则该时 间段的持续时间需设置得越短, 以使得内存可满足该时间段的数据的存储。
其中, 可在将所述第一内存管理列表或第二内存管理列表内的内存地 址所存储的数据存入数据库之后, 释放该内存地址所对应的内存。 藉此, 可使得内存的资源得到及时释放, 以便所释放的资源可用于后续的所需存 储的数据或用于其他用途, 实现内存的动态分配及释放。
其中, 所述针对第二时间段和第三时间段的步骤可循环交替执行, 即 在一时间段, 以第一内存管理列表来管理用于写入数据的内存地址, 与此 同时, 读取第二内存管理列表所包含的内存地址所存储的数据, 并将该数 据存入数据库; 在之后的另一时间段, 以第二内存管理列表来管理用于写 入数据的内存地址, 于此同时, 读取第一内存管理列表所包含的内存地址 所存储的数据, 并将该数据存入数据库; 之后, 再以第一内存管理列表来 管理用于写入数据的内存地址, 于此同时, 读取第二内存管理列表所包含 的内存地址所存储的数据, 并将该数据存入数据库。 藉此, 可不断轮换第 一内存管理列表与第二内存管理列表的功能 (即, 分别用于写入数据与读 取数据), 实现大量连续数据的存储, 执行效率高。
其中, 该方法还包括: 建立读写标志, 该读写标志每隔预设时间 (例 如, 10秒) 于第一值 (例如, 1 ) 与第二值 (例如, 2) 之间切换一次, 所 述第一时间段、 第二时间段以及第三时间段之间的切换根据该读写标志的 改变而进行。 该读写标志的具体使用过程将在下文中结合图 3A-3C进行详 细描述。 当然, 第一时间段、 第二时间段以及第三时间段之间的切换并非 必须借助该读写标志实现, 亦可通过于程序内设定其他切换条件 (诸如, 当所述内存所存储的数据达到容量上限时) 而实现。
图 2B为本发明第一实施方式的数据存储方法的执行过程示意图。如图 2B所示,在此假设第一和第二内存管理列表所管理的内存地址均是固定的, 分别对应于内存内的缓冲区 A和缓冲区 B, 以便于进行说明。在时间段 tl, 缓冲区 A和缓冲区 B均为空。 在时间段 t2, 将网络终端 310所发送的数据 写入缓冲区 A。 在时间段 t3, 将网络终端 310所发送的数据写入缓冲区 B, 同时读取所述缓冲区 A所存储的数据, 并将该数据写入数据库 110, 之后 释放缓冲区 A。 在时间段 t4, 将网络终端 310所发送的数据写入缓冲区 A, 同时读取所述缓冲区 B所存储的数据,并将该数据写入数据库 110,之后释 放缓冲区 B。在时间段 t5, 将网络终端 310所发送的数据写入缓冲区 B, 同 时读取所述缓冲区 A所存储的数据, 并将该数据写入数据库 110, 之后释 放缓冲区 A (该时间段 t3所执行的操作与上述时间段 t3所执行的操作相 同)。 循环交替执行与上述时间段 t3和 t4所执行操作相同的操作, 直至时 间段 tn。 藉此, 对大量连续到来的所需存储的数据进行无间断写入与读取 并存入数据库 110的操作, 提高了数据存储效率。
图 3A-3C以图 1A所示的搅拌站系统为例, 示出了本发明第一实施方 式的上述异步数据存储方法的流程图。 以下结合图 3A-3C对本发明的数据 存储方法的具体实施方式进行描述。
如图 3A-3C所示, 异步数据存储通过两个线程执行, 即主线程与数据 存储线程, 其中该数据存储线程由主线程所创建, 且主线程创建该数据存 储线程的同时, 创建读写标志、 第一内存管理列表和第二内存管理列表。 图 3A示出了主线程的操作流程(于此省略了创建数据存储线程以及创建读 写标志、 第一内存管理列表和第二内存管理列表的操作), 如图 3A所示, 数据服务器 100的主线程启动数据服务器 100的通信功能, 之后等待数据, 并在收到来自车载终端 300 的数据之后, 对该数据进行解析, 在该数据为 有效数据的情况下, 将该数据发送至数据存储线程, 并在该数据服务器 100 的图形界面上显示该数据; 在该数据为无效数据的情况下, 丢弃该数据。 之后, 主线程判断是否退出通信, 如果是, 则关闭通信功能, 如果否, 则 继续回到上述等待数据的步骤。 其中, 所述对数据是否为有效数据的判断 可通过包含于数据内的校验码来进行校验, 该校验例如可为奇偶校验、 HASH校验或 MD5校验等。
图 3B示出了数据存储线程的写入缓冲区的操作流程, 图 3C示出了数 据存储线程的读取缓冲区并存入数据库的操作流程, 图 3B与图 3C所示的 操作并行运行。
如图 3B所示, 数据存储线程接收来自主线程的数据, 将该数据写入内 存, 并判断读写标志, 当读写标志为 1 时, 将所写入的内存地址加入至第 一内存管理列表; 当读写标志为 2 时, 将所写入的内存地址加入至第二内 存管理列表。
如图 3C所示, 数据存储线程每隔一预定时间, 进行一次将第一或第二 内存管理列表内的内存地址所存储的数据存入数据库的操作, 并与此同时, 切换第一内存管理列表与第二内存管理列表的功能。 首先, 数据存储线程 判断数据库是否已连接, 当未连接数据库时, 进行连接数据库的操作; 当 已连接数据库时, 判断读写标志, 当读写标志为 1时, 将读写标志置为 2, 读取第一内存管理列表内的内存地址所存储的数据, 将该数据存入数据库, 并释放该内存地址所对应的内存, 从第一内存管理列表中删除该内存地址; 当读写标志为 2时, 将读写标志置为 1, 读取第二内存管理列表内的内存地 址所存储的数据, 将该数据存入数据库, 并释放该内存地址所对应的内存, 从第二内存管理列表中删除该内存地址。 之后, 判断是否退出该数据存储 线程, 如果不退出, 则重新进入等待时期并在此之后执行以上操作; 如果 退出, 则须读取第一和第二内存管理列表内的内存地址所存储的数据, 将 该数据存入数据库内, 并释放该内存地址所对应的内存以及第一和第二内 存管理列表, 藉此于数据存储线程退出之前, 完成第一和第二内存管理列 表内的内存地址所存储的所有数据存入数据库的操作。
在图 3C所示操作中, 在判断读写标志时, 假设读写标志为 1, 则将读 写标志置为 2, 读取第一内存管理列表内的内存地址所存储的数据,将该数 据存入数据库, 并释放该内存地址所对应的内存, 从第一内存管理列表中 删除该内存地址, 之后数据存储线程进入等待时期, 并于等待预定时间之 后, 重新执行以上操作。 此时, 读写标志为 2, 则读取第二内存管理列表内 的内存地址所存储的数据, 将该数据存入数据库, 并释放该内存地址所对 应的内存, 从第二内存管理列表中删除该内存地址。 藉此, 可实现第一内 存管理列表与第二内存管理列表的交替读取。
另外, 就数据存储线程的将内存地址加入至内存管理列表的操作而言, 当读写标志为 1 时, 数据存储线程将所接收的数据所被写入的内存地址加 入至第一内存管理列表; 于此同时, 当数据存储线程经历等待时间之后, 由于读写标志为 1, 其将读写标志置为 2 (此后所接收的数据所被写入的内 存地址将被加入至第二内存管理列表), 读取第一内存管理列表内的内存地 址所存储的数据, 将该数据存入数据库, 并释放该内存地址所对应的内存, 从第一内存管理列表中删除该内存地址。 藉此, 可实现第一内存管理列表 与第二内存管理列表的功能的交替变换, 对大量连续到来的所需存储的数 据进行无间断写入与读取并存入数据库的操作, 提高了数据存储效率。 第二实施方式
如图 4A所示,本发明第二实施方式的数据存储方法包括:创建缓冲区、 读指针以及写指针, 该读指针及写指针位于该缓冲区头部; 以及通过移动 所述写指针, 将所需存储的数据写入所述缓冲区, 同时通过移动所述读指 针, 读取所述缓冲区内所写入的数据, 并将该数据存入数据库内。 藉此, 可通过写指针进行数据写入, 并同时利用读指针进行数据读取及存入数据 库, 可实现数据的异步存储。 当将其应用至图 1A所示的搅拌站系统时, 可 实现数据的连续接收, 而无需在数据存入数据库之后方才能够接收下一数 据, 执行效率高, 占用 CPU时间片少。
其中, 当所述读指针和写指针移动到所述缓冲区尾部时, 该读指针和 写指针返回至所述缓冲区头部。 藉此, 可在缓冲区已存满数据的情况下, 实现缓冲区的循环使用。
图 4B为图 4A所示的数据存储方法的执行过程示意图。如图 4B所示, 左侧附图示出了缓冲区未被写满时的情形, 右侧附图示出了缓冲区已被写 满且写指针返回至缓冲区头部的情形。 相应地, 本发明还提供一种搅拌站通信服务器, 该服务器包括: 数据 接收装置, 用于接收数据; 存储装置, 包含多个缓冲区; 以及处理器, 与 所述数据接收装置和存储装置相连, 用于: 在第一时间段, 将所述数据接 收装置于该时间段所接收的数据写入多个缓冲区内的第一缓冲区; 以及在 第二时间段, 将所述数据接收装置于该时间段所接收的数据写入所述多个 缓冲区内的第二缓冲区, 将之前的时间段已写入数据的缓冲区内的数据存 入数据库。
其中, 所述处理器还可用于在第三时间段, 将该时间段所接收的数据 写入所述第一缓冲区或所述多个缓冲区内的第三缓冲区, 将之前的时间段 已写入数据的缓冲区内的数据存入数据库。
其中, 所述处理器还可用于在将之前的时间段已写入数据的缓冲区内 的数据存入所述数据库之后, 释放该缓冲区。
其中, 所述处理器可交替执行所述针对第二时间段和第三时间段的步 骤循环。
相应地, 本发明还提供一种搅拌站系统, 该系统包括: 车载终端, 用 于发送数据; 以及上述搅拌站通信服务器。
相应地, 本发明还提供一种搅拌站, 该搅拌站包括上述搅拌站通信服 务器。
该搅拌站通信服务器、 搅拌站系统以及搅拌站的其他细节及优点与上 述用于搅拌站通信服务器的数据存储方法相同, 于此不再赘述。
通过使用本发明, 可向一缓冲区内写入数据, 并在该数据未被存入数 据库的情况下, 接收下一数据, 并将该数据存入另一缓冲区, 与此同时从 写有数据的缓冲区读取数据并将该数据存入数据库内。 该过程与需在数据 存入数据库之后方才能够接收下一数据的阻塞存储模式相比, 将数据存入 数据库这种 I/O操作可由一线程独立执行, 数据的接收不需要等待其他工 作, 从而可不断接收数据, 并于此同时不断将之前所接收的数据存入数据 库内, 执行效率高, 占用 CPU时间片少, 且实现了缓冲区的动态分配及释 放。 将本发明应用至搅拌站系统, 可明显提高来自车载终端的数据接收及 存储速度, 解决网络状况较差以及大量车载终端并发的情况所存在的问题。
以上结合附图详细描述了本发明的优选实施方式, 但是, 本发明并不 限于上述实施方式中的具体细节, 在本发明的技术构思范围内, 可以对本 发明的技术方案进行多种简单变型, 这些简单变型均属于本发明的保护范 围。
另外需要说明的是, 在上述具体实施方式中所描述的各个具体技术特 征, 在不矛盾的情况下, 可以通过任何合适的方式进行组合。 为了避免不 必要的重复, 本发明对各种可能的组合方式不再另行说明。
此外, 本发明的各种不同的实施方式之间也可以进行任意组合, 只要 其不违背本发明的思想, 其同样应当视为本发明所公开的内容。

Claims

权利要求
1、 一种用于搅拌站通信服务器的数据存储方法, 其特征在于, 该方法 包括:
在第一时间段, 接收数据, 并将该时间段所接收的数据写入多个缓冲 区中的第一缓冲区; 以及
在第二时间段, 接收数据, 并将该时间段所接收的数据写入所述多个 缓冲区中的第二缓冲区, 将之前的时间段已写入数据的缓冲区内的数据存 入数据库。
2、 根据权利要求 1所述的方法, 其特征在于, 该方法还包括: 在第三时间段, 将该时间段所需存储的数据写入所述第一缓冲区或所 述多个缓冲区中的第三缓冲区, 读取之前的时间段内已写入数据的缓冲区 内的数据存入数据库。
3、 根据权利要求 1或 2所述的方法, 其特征在于, 在将所述之前的时 间段已写入数据的缓冲区内的数据存入所述数据库之后, 释放该缓冲区。
4、 根据权利要求 2所述的方法, 其特征在于, 所述针对第二时间段和 第三时间段的步骤循环交替执行。
5、 一种搅拌站通信服务器, 其特征在于, 该服务器包括:
数据接收装置, 用于接收来自车载终端的数据;
存储装置, 包含多个缓冲区; 以及
处理器, 与所述数据接收装置和存储装置相连, 用于:
在第一时间段, 将所述数据接收装置于该时间段所接收的数据写 入多个缓冲区内的第一缓冲区; 以及
在第二时间段, 将所述数据接收装置于该时间段所接收的数据写 入所述多个缓冲区内的第二缓冲区, 将之前的时间段已写入数据的缓冲区 内的数据存入数据库。
6、 根据权利要求 5所述的服务器, 其特征在于, 所述处理器还用于在 第三时间段, 将该时间段所接收的数据写入所述第一缓冲区或所述多个缓 冲区内的第三缓冲区, 将之前的时间段已写入数据的缓冲区内的数据存入 数据库。
7、 根据权利要求 5或 6所述的服务器, 其特征在于, 所述处理器还用 于在将之前的时间段已写入数据的缓冲区内的数据存入所述数据库之后, 释放该缓冲区。
8、 根据权利要求 6所述的服务器, 其特征在于, 所述处理器交替执行 所述针对第二时间段和第三时间段的步骤循环。
9、 一种搅拌站系统, 其特征在于, 该系统包括:
车载终端, 用于发送数据; 以及
10、一种搅拌站, 其特征在于, 该搅拌站包括权利要求 6-8中任一项权 要求所述的服务器。
PCT/CN2011/080926 2011-10-18 2011-10-18 搅拌站以及用于该搅拌站的数据存储方法、服务器、系统 WO2013056420A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2011/080926 WO2013056420A1 (zh) 2011-10-18 2011-10-18 搅拌站以及用于该搅拌站的数据存储方法、服务器、系统

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2011/080926 WO2013056420A1 (zh) 2011-10-18 2011-10-18 搅拌站以及用于该搅拌站的数据存储方法、服务器、系统

Publications (1)

Publication Number Publication Date
WO2013056420A1 true WO2013056420A1 (zh) 2013-04-25

Family

ID=48140302

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/080926 WO2013056420A1 (zh) 2011-10-18 2011-10-18 搅拌站以及用于该搅拌站的数据存储方法、服务器、系统

Country Status (1)

Country Link
WO (1) WO2013056420A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103593148A (zh) * 2013-11-08 2014-02-19 大唐移动通信设备有限公司 一种cdf侧离线话单数据快速存取的方法及装置
CN103678171A (zh) * 2013-12-10 2014-03-26 北京京诚瑞达电气工程技术有限公司 变频器数据曲线实时记录方法及装置
CN107483255A (zh) * 2017-08-23 2017-12-15 四川隧唐科技股份有限公司 拌合站数据处理方法、装置及系统

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5163132A (en) * 1987-09-24 1992-11-10 Ncr Corporation Integrated controller using alternately filled and emptied buffers for controlling bi-directional data transfer between a processor and a data storage device
US5757381A (en) * 1996-04-04 1998-05-26 Sofmap Future Design, Inc. Methods for fast scrolling of images
CN101414973A (zh) * 2008-11-25 2009-04-22 中国人民解放军信息工程大学 一种传输数据包的方法及装置
CN101441610A (zh) * 2007-11-21 2009-05-27 中兴通讯股份有限公司 一种实现数据并串转换无缝输出的系统及方法
CN101727403A (zh) * 2008-10-15 2010-06-09 深圳市朗科科技股份有限公司 数据存储系统、设备及方法
CN102122256A (zh) * 2011-03-28 2011-07-13 中国人民解放军国防科学技术大学 一种用于进程间通信的管道式通信方法及系统
CN102360338A (zh) * 2011-10-18 2012-02-22 中联重科股份有限公司 搅拌站以及用于该搅拌站的数据存储方法、服务器、系统

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5163132A (en) * 1987-09-24 1992-11-10 Ncr Corporation Integrated controller using alternately filled and emptied buffers for controlling bi-directional data transfer between a processor and a data storage device
US5757381A (en) * 1996-04-04 1998-05-26 Sofmap Future Design, Inc. Methods for fast scrolling of images
CN101441610A (zh) * 2007-11-21 2009-05-27 中兴通讯股份有限公司 一种实现数据并串转换无缝输出的系统及方法
CN101727403A (zh) * 2008-10-15 2010-06-09 深圳市朗科科技股份有限公司 数据存储系统、设备及方法
CN101414973A (zh) * 2008-11-25 2009-04-22 中国人民解放军信息工程大学 一种传输数据包的方法及装置
CN102122256A (zh) * 2011-03-28 2011-07-13 中国人民解放军国防科学技术大学 一种用于进程间通信的管道式通信方法及系统
CN102360338A (zh) * 2011-10-18 2012-02-22 中联重科股份有限公司 搅拌站以及用于该搅拌站的数据存储方法、服务器、系统

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103593148A (zh) * 2013-11-08 2014-02-19 大唐移动通信设备有限公司 一种cdf侧离线话单数据快速存取的方法及装置
CN103593148B (zh) * 2013-11-08 2017-10-27 大唐移动通信设备有限公司 一种cdf侧离线话单数据快速存取的方法及装置
CN103678171A (zh) * 2013-12-10 2014-03-26 北京京诚瑞达电气工程技术有限公司 变频器数据曲线实时记录方法及装置
CN107483255A (zh) * 2017-08-23 2017-12-15 四川隧唐科技股份有限公司 拌合站数据处理方法、装置及系统

Similar Documents

Publication Publication Date Title
CN111756811B (zh) 一种分布式系统的主动推送的方法、系统、设备及介质
US10609150B2 (en) Lock management method in cluster, lock server, and client
CN111147564B (zh) 数据文件传输方法、系统及通信终端
WO2017133623A1 (zh) 一种数据流处理方法、装置和系统
WO2021254330A1 (zh) 内存管理方法、系统、客户端、服务器及存储介质
US9699276B2 (en) Data distribution method and system and data receiving apparatus
CN102447610B (zh) 实现报文缓存资源共享的方法和装置
WO2011023068A1 (zh) 一种个人网设备获取业务内容的装置、方法及相关装置
CN113179327B (zh) 基于大容量内存的高并发协议栈卸载方法、设备、介质
WO2012031436A1 (zh) 数据存储与鉴权并行的处理方法和终端
US8848532B2 (en) Method and system for processing data
WO2018049873A1 (zh) 一种应用调度方法及装置
WO2013044628A1 (zh) 在Nginx上实现云缓存的REST接口的方法和系统
WO2017032152A1 (zh) 将数据写入存储设备的方法及存储设备
CN109831394B (zh) 数据处理方法、终端以及计算机存储介质
WO2013056420A1 (zh) 搅拌站以及用于该搅拌站的数据存储方法、服务器、系统
CN116204487A (zh) 远程数据访问方法及装置
US10318362B2 (en) Information processing apparatus, information processing method, and non-transitory computer-readable storage medium
CN111404842B (zh) 数据传输方法、装置及计算机存储介质
CN114911632B (zh) 一种进程间通信的控制方法和系统
JPH10228445A (ja) リングバス入出力制御装置
US20230393782A1 (en) Io request pipeline processing device, method and system, and storage medium
TWI635396B (zh) 使用兩階記憶體處理封包資料之資料傳輸系統、資料接收方法、及資料傳送方法
WO2022151970A1 (zh) 一种数据传输方法、系统以及计算节点
CN105471930A (zh) 一种读取分布式数据的方法、系统和设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11874289

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11874289

Country of ref document: EP

Kind code of ref document: A1