CN108959527A - The method for reading display interlocking log based on Windows file mapping technology - Google Patents

The method for reading display interlocking log based on Windows file mapping technology Download PDF

Info

Publication number
CN108959527A
CN108959527A CN201810691686.1A CN201810691686A CN108959527A CN 108959527 A CN108959527 A CN 108959527A CN 201810691686 A CN201810691686 A CN 201810691686A CN 108959527 A CN108959527 A CN 108959527A
Authority
CN
China
Prior art keywords
file
log
record
data
recordonly
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN201810691686.1A
Other languages
Chinese (zh)
Other versions
CN108959527B (en
Inventor
余日可
马雯
马锐
韦启盟
杨平
陈小猛
李新新
宁丽敏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Casco Signal Ltd
Original Assignee
Casco Signal Ltd
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 Casco Signal Ltd filed Critical Casco Signal Ltd
Priority to CN201810691686.1A priority Critical patent/CN108959527B/en
Publication of CN108959527A publication Critical patent/CN108959527A/en
Application granted granted Critical
Publication of CN108959527B publication Critical patent/CN108959527B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0656Data buffering arrangements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The present invention relates to a kind of methods for reading display interlocking log based on Windows file mapping technology, comprising: step 1 specially arouses an individual thread ReadLogThread and executes reading and deletes the function of selecting log;Step 2, ReadLogThread execute function using WaitForMultipleObjects mode waiting signal amount triggering function;Step 3, when have semaphore triggering WaitForMultipleObjects in signal when, first call InitOneMonthFMap initialization Windows File Mapping pointer;After the completion of step 4, InitOneMonthFMap, SearchbyTypeKeyWord is called successively to browse relevant whole journal files, and wherein content is parsed, it is an individual journal file recordonly.dat by the address information recording of wherein satisfactory journal entries;Step 5, according to the size of recordonly.dat file, the data volume of record, calculating needs log item number nRecordCount to be shown, and the number of entries of empty list to be shown will be needed to be set as nRecordCount etc..Compared with prior art, the present invention has many advantages, such as high-efficient, saving memory headroom.

Description

The method for reading display interlocking log based on Windows file mapping technology
Technical field
The present invention relates to Windows file mapping technology fields, are based on Windows File Mapping skill more particularly, to one kind The method that art reads display interlocking log.
Background technique
For the demand safeguarded and played back to interlock system, need to record the various information in interlock system operational process. To form a large amount of interlocking log.And in order to have access to interlocking log when needed, interlocking maintenance console then has log query Function.
Interlocking log recording and look facility are of great significance in interlock system.It is the next that interlock system is divided into interlocking Machine, interlocked operation machine and interlocking maintenance console.Interlocking slave computer is responsible for running ground installation, and interlocked operation machine is responsible for sending operation Order, and check that yard indicates.And equipment daily maintenance, then it is the basic function for interlocking maintenance console.Interlock maintenance console for The daily maintenance of interlock device, the recording and displaying by interlocking log are realized.When interlock system breaks down, interlocking Maintenance personnel and is combined with the condition that concerns feeling in the log for checking interlocking maintenance console historical record, can with precise positioning fault point, thus It lays the foundation for on-call maintenance.
Interlocking log recording and look facility are of great significance in interlock system.It interlocks slave computer and only runs function Can, without display function.Interlocked operation machine has the function of display function and certain log history data, but the content that can be recorded It is limited.In order to have access to the interlocking log of needs in time when needed, interlocking maintenance console needs the record of all matters, big and small to join The operating condition of lock.With the development of interlock system, the log for interlocking maintenance console record is more and more detailed, and log amount is increasingly Greatly.In this background, the method for original reading interlocking log based on IO stream functionally seem lower and lower under, read It takes speed low, in order to show in time after reading, and log content must be loaded in memory, thus to program internal memory Produce biggish load.Such design presence is not scientific, can not adapt to increasingly developed industry requirement.
Summary of the invention
It is an object of the present invention to overcome the above-mentioned drawbacks of the prior art and provide one kind based on Windows text The method that part mapping techniques read display interlocking log.
The purpose of the present invention can be achieved through the following technical solutions:
A method of display interlocking log is read based on Windows file mapping technology, method includes the following steps:
Step 1 specially arouses an individual thread ReadLogThread and executes reading and deletes the function of selecting log;
Step 2, ReadLogThread are held using WaitForMultipleObjects mode waiting signal amount triggering function Row function;
Step 3, when have semaphore triggering WaitForMultipleObjects in signal when, first call The pointer of InitOneMonthFMap initialization Windows File Mapping;
After the completion of step 4, InitOneMonthFMap, SearchbyTypeKeyWord is called successively to browse relevant complete Portion's journal file, and wherein content is parsed, it is one individual by the address information recording of wherein satisfactory journal entries Journal file recordonly.dat;
Step 5, according to the size of recordonly.dat file, the data volume of record, calculating needs log item to be shown Number nRecordCount, and the number of entries of empty list to be shown will be needed to be set as nRecordCount;
Step 6 when showing inside virtual list, calls GetRecordContent acquisition that should be shown in this line Log content;
Step 7, in GetRecordContent, be quickly calculated according to line number and to be recorded in recordonly.dat Address value in corresponding journal entries content in log text itself, and log text is directly gone according to the address value of reading Log is read in itself, and then is shown on interface.
Preferably, the initialization files pointer in the step 3 specifically includes the following steps:
Step 3.1 sees whether the member in file pointer group m_mapFileH_Month is previously used, if used, File, releasing memory are then closed, and corresponding member in corresponding file size array m_FileSize_Month is set 0;
Step 3.2, recursive call CreateFileDBMapping initialization files group to file pointer group m_ MapFileH_Month, and each file size is obtained, assignment corresponding member into length array m_FileSize_Month.
Preferably, in the step 4 and step 5 according to the log of given search conditional search and to generate index file specific The following steps are included:
Step 4.1, the semaphore for clicking " load " or the triggering WaitForMultipleObjects waiting of " search " button;
Step 4.2, by " search " and the ashing of " load " button, avoid before loaded trigger signal amount repeatedly;
Step 4.3 checks for recordonly.dat index file, if it is present destroying;
Step 4.4, creation recordonly.dat file, and its file pointer is recorded to class members m_fpselected_ record;
Step 4.5 will be needed to browse in range by file number recursive call SearchFromOneLogFlieRecord File in order successively browsing read, delete and select all logs, and m_ is recorded in qualified log address In fpselected_record;
Need entry number nRecordCount to be shown is calculated according to index file size, and is arranged for step 4.6 The number of entries of virtual list is nRecordCount;
Step 4.7, closing file pointer m_fpselected_record and normalization " load " and " search " button.
Preferably, SearchFromOneLogFlieRecord is called to specifically include following step in described step 4.5 It is rapid:
Step 4.5.1, judge that m_fpselected_record for sky, is then exited if it is sky;
Step 4.5.2, MapViewOfFile is called, by corresponding file by the file on hard disk according to every time by m_ AllocationGranularity size is mapped in memory pointer mapH;
Step 4.5.3, the m_ for calling DealWithLogItemRecord processing MapViewOfFile to read out The data block of AllocationGranularity byte-sized;
Step 4.5.4, judge whether to reach end of file, if reached, exit the program;Step is transferred to if not Rapid 4.5.2 reads next data block of file.
Preferably, DealWithLogItemRecord function is called to specifically include following step in the step 4.5.3 It is rapid:
Step 4.5.3.1, determine whether the character stream of input is the initial data block of the journal file, if it is not, inciting somebody to action Input data flows to ‘ r ', and ' n ' and data content before copy to the previous piece of character array tailcontent stayed In, so that tailcontent is become a complete record, and call MatchStrInStr and ParseFilterContentRecord carries out deleting choosing;
Step 4.5.3.2, untreated byte subscript is recorded as index;
Step 4.5.3.3, it from i-th ndex byte poll backward, often encounters ' r " n ' and is then recorded as a complete note Record;
Step 4.5.3.4, judge whether it is completely to record, if it is not, then remaining content assignment is arrived In tailcontent;
Step 4.5.3.5, determine whether keyword is empty in search condition, if it is not, MatchStrInStr is called to pick Except the log recording for not including this keyword;
Step 4.5.3.6, it calls ParseFilterContentRecord to delete by type and selects qualified log note Record;
Step 4.5.3.7, whether end of file is reached, if it is, exiting;
Step 4.5.3.8, step step 4.5.3.3 is gone to.
Preferably, ParseFilterContentRecord is called to carry out parsing specific packet in the step 4.5.3.1 Include following steps:
Step 4.5.3.1.1, the input structure of defined function first:
Step 4.5.3.1.2, index value ind and count value count is initialized;
Step 4.5.3.1.3, ind < contentlen is determined, if so, step 4.5.3.1.4 is executed, if it is not, saying Bright browsed finishes, and exits the program;
Step 4.5.3.1.4, then determine tailcontent [ind]!=' * ', if it is, ind++, is transferred to step 4.5.3.1.2 if it is not, then executing step 4.5.3.1.5;
Step 4.5.3.1.5, then determine whether count can filter out the particular value of record type, if so, executing step 4.5.3.1.7 if it is not, executing step 4.5.3.1.6;
Step 4.5.3.1.6, then count++, ind+=3, and it is transferred to step 4.5.3.1.2;
Step 4.5.3.1.7, record type value is extracted from record to typecur and is compared with type Operation;
Step 4.5.3.1.8, judge whether typecur meets type and delete choosing requirement, if it is not, then return -1, is exited Program, if so, executing step 4.5.3.1.9;
Step 4.5.3.1.9, then Fileindex, mpa_data_offset, tailoffset are recorded In recordonly.dat.
Preferably, the input structure of the defined function specifically:
char*tailcontent;The beginning of // a line log,
DWORD contentlen;The length of // a line log,
DWORD mpa_data_offset;// this row log is located at which blocks of files of the journal file,
DWORD tailoffset;// this row log be located at this document block which oneself start,
FILE*fp;The file pointer of //recordonly.dat,
ULONG type;The searching class offset of // input,
USHORT fileindex;// log is located at which file in file.
Preferably, journal entries to be shown are needed specifically to wrap by index file recordonly.dat file quick obtaining Include following steps:
Step 9.1 will need record subscript index value iItemIndx to be shown as input first;
The starting point for m_fpselected being moved on to the section that needs are read is calculated according to iItemIndx for step 9.2 Location;
Step 9.3 reads Fileindex, map_data_offset from m_fpselected_record, and tail_offset;
Step 9.4, from file pointer array m_mapFileH_Month [] and file size array m_FileSize_ Corresponding file pointer mapfilehandle and file size FileSize is fetched into Month [];
Step 9.5 calls MapViewOfFile that the content in journal file is mapped directly to character string pointer m_ mapH;
Step 9.6 checks whether this part map_data_offset and the content deviated in tail_offset read enough Take current line, i.e. this log end for being exactly the record block, it is complete either with or without reading, if it does, being then transferred to step Rapid 9.7, if not, then it is transferred to step 9.8;
Step 9.7 calls GetLine1 and wherein will be transferred to step 9.10 into prec by Context resolution;
Step 9.8 reads file data by the incomplete data backup of this block of tail portion, and using MapViewOfFile Next piece, then by next piece of header contents assignment of reading to the front of previous piece of tail data, formed one it is complete Data record;
Step 9.9, call GetLine2 and will wherein Context resolution into prec;
Step 9.10 exits the program.
Preferably, the method further include:
Step 8, the search method for other searching requirements, type delete choosing, and character string includes to double-click certain cell with aobvious Showing the column entirely is and double-clicks the identical content of cell, waits the algorithm of any original search condition of modification, is both needed to search condition After clear, then S4 is gone to step, regenerates index file recordonly.dat.
Compared with prior art, the invention has the following advantages that
1, the present invention using Windows provide own files mapping technical solution read journal file, efficiency than Traditional I/O stream is much higher.Memory Mapping File is by the mapping of a file to the process address space.In Win32, each process There is the address space of oneself, a process cannot access the data in another process address space easily, so cannot picture 16 Windows are done like that.Win32 system allows multiple processes (operation is on the same computer) to come using Memory Mapping File Shared data.In this way, the data in file can be accessed with memory read/write instruction, rather than with ReadFile and I/O system function as WriteFile, to improve file access speed.The operation of traditional I/O stream has carried out data copy, Its buffer area first by file content from disk copy to kernel spacing, then again by these data copies to user's sky Between, in this process, it has been actually accomplished data copy twice.And the direct mapped file address of method that file directly maps To user's space, so interrupt processing function is according to this mapping relations, directly by file from disk copy to user's space, only A data copy is carried out.Therefore, the efficiency of memory mapping reading file is more much higher than traditional I/O stream.
2, the technical solution for the own files mapping that the present invention is provided using Windows reads journal file, is conducive to save About memory headroom.Memory Mapping File is in the address space using virtual memory File Mapping to process, after this Process operation file, just as the address of the operation process space.Centre does not need for the content of log to be loaded into memory It goes, so that program internal memory be greatly saved.
3, the technical solution for the own files mapping that the present invention is provided using Windows reads journal file, breaks through completely Limitation of the size of journal file for program.Cause journal file odd big incomparable under this scene special for certain comparisons The case where it is especially suitable.
4, the technical solution for the own files mapping that the present invention is provided using Windows reads journal file, in PC machine In the case that energy is bad, the more obvious operational efficiency that ensure that main program of efficiency enhancement effect.Traditional utilizes IO stream load The method of log needs first to be loaded into memory journal file.As journal file load is more and more, PC machine residue is available Memory headroom is smaller.And the free memory of PC machine directly influences program operational efficiency.The own files provided using Windows The technical solution of mapping reads journal file, any additional memory headroom is not loaded with, so that the operation for main program provides Enough remaining spaces, and then ensure that the operational efficiency of main program.
5, the present invention is conducive to quickly position the ground for needing journal file to be shown using the method for establishing log index Location does not need to search whole journal file spaces again, is effectively promoted and read log efficiency in display.Search suitable log item When mesh, the address set of the entry of log to be shown will be needed at a readable index binary file.It is first every time when display The address information in journal file for first reading log recording from index binary file depending on the relative position, further according to reading Address information, position rapidly and read journal entries itself, greatly improve the efficiency.
6, the present invention is when show log, using the form of virtual list, has saved a large amount of original needs loads and has existed Control on MFC control.When showing content in common list, journal entries itself is needed to be loaded on list control. This often leads to MFC control inherently unbearable excessive log amount, so as to cause the collapse of program.Using virtual list Form, each MFC control only need to load needs in 20 items being shown on interface.The memory that needs to consume it is few again It is few, to develop slim and graceful efficiently program.
Detailed description of the invention
Fig. 1 is program main flow schematic diagram;
Fig. 2 is initialization files pointer figure;
Fig. 3 is according to the log of given search conditional search and to generate index file flow chart;
Fig. 4 is that browsing single file generates index file flow chart;
Fig. 5 is function DealWithLogItemRecord flow chart;
Fig. 6 is MatchStrInStr flow chart;
Fig. 7 is ParseFilterContentFault flow chart;
Fig. 8 is that quick obtaining needs journal entries flow chart to be shown;
Fig. 9 is GetLine1 flow chart;
Figure 10 is GetLine2 flow chart.
Specific embodiment
The technical scheme in the embodiments of the invention will be clearly and completely described below, it is clear that described implementation Example is a part of the embodiments of the present invention, rather than whole embodiments.Based on the embodiments of the present invention, ordinary skill Personnel's every other embodiment obtained without making creative work all should belong to the model that the present invention protects It encloses.
Program main flow of the invention as shown in Figure 1, method realizes function using the method for individually arousing a thread, The following steps are included:
Step 100, the precondition of search is set;
Step 101, trigger signal makes function start to execute starting;
Step 102, function InitOneMonthFMap initialization files pointer etc. is called;
Step 103, it calls SearchbyTypeKeyWord successively to browse relevant whole journal files, and parses wherein The address information recording of wherein satisfactory journal entries is an individual journal file by content recordonly.dat;
Step 104, according to the size of recordonly.dat file, the data volume of record, calculating needs log to be shown Item number nRecordCount.And the number of entries of empty list to be shown will be needed to be set as nRecordCount;
Step 105, when showing inside virtual list, call GetRecordContent (line number) acquisition that should be shown in The log content of this line.Its implementation procedure is that the correspondence recorded in recordonly.dat is quickly calculated according to line number Journal entries content in address value in log text itself, and log text itself is directly gone according to the address value of reading Middle reading log, and then be shown on interface;
Step 106, search is re-executed if necessary, then needs to reset the precondition of search, i.e. execution step 100。
The process of initialization files pointer is as shown in Fig. 2, program must will be opened according to time span determination in the present invention File group.The file group of opening is too many, then waste of resource.It is very little to open file group, then is not able to satisfy functional requirement, including with Lower step:
Step 201 sees whether the member in file pointer group m_mapFileH_Month is previously used, if used, File, releasing memory are then closed, and corresponding member in corresponding file size array m_FileSize_Month is set 0;
Step 202, recursive call CreateFileDBMapping initialization files group to file pointer group m_ MapFileH_Month, and each file size is obtained, assignment corresponding member into length array m_FileSize_Month;
CreateFileDBMapping mainly realizes code are as follows:
As shown in figure 3, it is of the invention according to the log of given search conditional search and generate index file process include with Lower step:
Step 301, the semaphore for clicking " load " or the triggering WaitForMultipleObjects waiting of " search " button;
Step 302, by " search " and the ashing of " load " button, avoid before loaded trigger signal amount repeatedly;
Step 303 checks for recordonly.dat index file.If it is present destroying;
Step 304, creation recordonly.dat file, and its file pointer is recorded to class members m_fpselected_ record;
Step 305 will be needed to browse in range by file number recursive call SearchFromOneLogFlieRecord File in order successively browsing read, delete and select all logs, and m_ is recorded in qualified log address In fpselected_record;
Need entry number nRecordCount to be shown is calculated according to index file size, and is arranged for step 306 The number of entries of virtual list is nRecordCount;
Step 307, closing file pointer m_fpselected_record and normalization " load " and " search " button.
Fig. 4 is the flow chart of the SearchFromOneLogFlieRecord referred in Fig. 3 in process of the present invention, SearchFromOneLogFlieRecord is responsible for browsing whole logs in single file, to decide whether to meet the requirements, and Log address is recorded in m_fpselected_record, comprising the following steps:
Step 401 judges m_fpselected_record for sky.It is then exited if it is sky;
Step 402 calls MapViewOfFile, can be by the file on hard disk according to every time by m_ by corresponding file AllocationGranularity size is mapped in memory pointer mapH;
Step 403, the m_ for calling DealWithLogItemRecord processing MapViewOfFile to read out The data block of AllocationGranularity byte-sized;
Step 404 judges whether to reach end of file, if reached, exit the program;Step is transferred to if not 402, read next data block of file.
Fig. 5 is the flow chart of the DealWithLogItemRecord function referred in Fig. 4 in present procedure process. It is m_AllocationGranularity word that DealWithLogItemRecord function, which is responsible for one data block size of processing, The data block of section.Generally 64K.Whole sentence in data block is directly disposed, and has not been if the beginning and end of data block has Whole record strip purpose, then combining the ending of a upper data block or next data block is not complete documentation entry Remainder is handled together, specifically includes the following steps:
Do are step 501, the character stream for determining input the initial data blocks of the journal file? if it is not, will input Data flow to ‘ r ', and ' n ' and data content before copy in the character array tailcontent that previous piece stays, and make Tailcontent becomes a complete record, and call MatchStrInStr and ParseFilterContentRecord into Row deletes choosing;
Untreated byte subscript is recorded as index by step 502;
Step 503, from i-th ndex byte poll backward, often encounter ' r " n ' and be then recorded as a complete record;
Step 504 judges whether it is completely to record.If it is not, then by remaining content assignment to tailcontent In;
Does step 505 determine that keyword is empty in search condition? if it is not, MatchStrInStr is called to reject not Log recording comprising this keyword;
Step 506, calling ParseFilterContentRecord are deleted select qualified log recording by type;
Whether step 507 reaches end of file, if it is, exiting;
Step 508 goes to 503.
Fig. 6 is the flow chart of the MatchStrInStr referred in flow chart 5 of the present invention.MatchStrInStr execution character The function of String matching.It is functionally equivalent to strstr function.But it can be character string ending that strstr function needs, which encounter ' 0 ' just,. And the character string read in the present invention will read the content of 64K byte every time, it is intermediate there is no ' 0 ' end mark, so if It is necessarily crossed the border using strstr function, it is therefore desirable to oneself realize that MatchStrInStr realizes the function of string searching.It realizes Code is as follows:
Fig. 7 is the ParseFilterContentFault function process that refers in Fig. 5 in the program circuit in the present invention Figure.ParseFilterContentFault is responsible for parsing the complete log recording of a line, and is carried out according to the types value of input Matching.If successful match, the index address value of record log is including following into binary file recordonly.dat Step:
The input structure of defined function first:
char*tailcontent;The beginning of // a line log
DWORD contentlen;The length of // a line log
DWORD mpa_data_offset;// this row log is located at which blocks of files of the journal file
DWORD tailoffset;// this row log be located at this document block which oneself start
FILE*fp;The file pointer of //recordonly.dat
ULONG type;The searching class offset of // input
USHORT fileindex;// log is located at which file in file
Step 601, initialization index value ind and count value count;
Step 602 determines whether ind is less than contentlen, if it is not, explanation has been browsed and finished, exits the program;
Step 603, if it is, determine tailcontent [ind]!=' * ', if it is, ind++, is transferred to step 602;
Step 604, if it is not, then determine count whether be the particular value that can filter out record type;
Step 605, if it is not, then count++, ind+=3, and be transferred to step 602;
Step 606, if so, record type value is extracted from record to typecur and is compared with type Compared with operation;
Whether step 607, typecur, which meet type, is deleted choosing requirement;If it is not, then returning to -1, exit the program;
Step 608, if it is, Fileindex, mpa_data_offset and tailoffset are recorded In recordonly.dat.
Above-mentioned Fig. 2~Fig. 7 describe how from huge log recording by the satisfactory log recording of needs Address index file recordonly.dat is recorded.As shown in figure 8, fast by index file recordonly.dat file Speed, which obtains, needs journal entries to be shown, comprising the following steps:
Record subscript index value iItemIndx to be shown will be needed as input first;
The starting point for m_fpselected being moved on to the section that needs are read is calculated according to iItemIndx for step 701 Location;
Step 702 reads Fileindex, map_data_offset from m_fpselected_record, and tail_offset;
Step 703, from file pointer array m_mapFileH_Month [] and file size array m_FileSize_ Corresponding file pointer mapfilehandle and file size FileSize is fetched into Month [];
Step 704 calls MapViewOfFile that the content in journal file is mapped directly to character string pointer m_ mapH;
Step 705, check this part map_data_offset, deviate tail_offset, in content whether read enough Take current line, i.e. this log end for being exactly the record block, it is complete either with or without reading, if it does, being then transferred to step Rapid 706;If not, then it is transferred to step 707;
Step 706 calls GetLine1 and wherein will be transferred to step 709 into prec by Context resolution;
Step 707 reads file data by the incomplete data backup of this block of tail portion, and using MapViewOfFile Next piece, then by next piece of header contents assignment of reading to the front of previous piece of tail data, formed one it is complete Data record;
Step 708, call GetLine2 and will wherein Context resolution into prec;
Step 709 exits the program.
Fig. 9 and Figure 10 is respectively the flow chart of GetLine1 and GetLine2.GetLine1 and GetLine2 is from one The algorithm that record is extracted and parsed according to the address of certain specific record in a data block.Difference is, GetLine1 It is to parse record in from this block number.And GetLine2 is then to record due to being recorded in this block number in imperfect, needs this After the ending of block number evidence and the beginning of next block number evidence are stitched together, could be formed a complete record and It is resolved in data structure.
GetLine1 partial code is accomplished by
GetLine2 partial code is accomplished by
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any Those familiar with the art in the technical scope disclosed by the present invention, can readily occur in various equivalent modifications or replace It changes, these modifications or substitutions should be covered by the protection scope of the present invention.Therefore, protection scope of the present invention should be with right It is required that protection scope subject to.

Claims (9)

1. a kind of method for reading display interlocking log based on Windows file mapping technology, which is characterized in that this method includes Following steps:
Step 1 specially arouses an individual thread ReadLogThread and executes reading and deletes the function of selecting log;
Step 2, ReadLogThread execute function using WaitForMultipleObjects mode waiting signal amount triggering function Energy;
Step 3, when have semaphore triggering WaitForMultipleObjects in signal when, first call InitOneMonthFMap Initialize the pointer of Windows File Mapping;
After the completion of step 4, InitOneMonthFMap, SearchbyTypeKeyWord is called successively to browse relevant whole days Will file, and wherein content is parsed, it is an individual log by the address information recording of wherein satisfactory journal entries File recordonly.dat;
Step 5, according to the size of recordonly.dat file, the data volume of record, calculating needs log item number to be shown NRecordCount, and the number of entries of empty list to be shown will be needed to be set as nRecordCount;
Step 6 when showing inside virtual list, calls GetRecordContent to obtain the log that be shown in this line Content;
Step 7, in GetRecordContent, the correspondence recorded in recordonly.dat is quickly calculated according to line number Journal entries content in address value in log text itself, and log text itself is directly gone according to the address value of reading Middle reading log, and then be shown on interface.
2. a kind of method that display interlocking log is read based on Windows file mapping technology according to claim 1, Be characterized in that, the initialization files pointer in the step 3 specifically includes the following steps:
Step 3.1 sees whether the member in file pointer group m_mapFileH_Month is previously used, if used, closes Closed file, releasing memory, and corresponding member in corresponding file size array m_FileSize_Month is set 0;
Step 3.2, recursive call CreateFileDBMapping initialization files group to file pointer group m_mapFileH_ Month, and each file size is obtained, assignment corresponding member into length array m_FileSize_Month.
3. a kind of method that display interlocking log is read based on Windows file mapping technology according to claim 1, Be characterized in that, in the step 4 and step 5 according to the log of given search conditional search and generate index file specifically include with Lower step:
Step 4.1, the semaphore for clicking " load " or the triggering WaitForMultipleObjects waiting of " search " button;
Step 4.2, by " search " and the ashing of " load " button, avoid before loaded trigger signal amount repeatedly;
Step 4.3 checks for recordonly.dat index file, if it is present destroying;
Step 4.4, creation recordonly.dat file, and its file pointer is recorded to class members m_fpselected_ record;
Step 4.5 will need to browse the text in range by file number recursive call SearchFromOneLogFlieRecord Successively browsing is read part in order, is deleted and is selected all logs, and m_ is recorded in qualified log address In fpselected_record;
Need entry number nRecordCount to be shown is calculated according to index file size for step 4.6, and is arranged virtual The number of entries of list is nRecordCount;
Step 4.7, closing file pointer m_fpselected_record and normalization " load " and " search " button.
4. a kind of method that display interlocking log is read based on Windows file mapping technology according to claim 3, Be characterized in that, call SearchFromOneLogFlieRecord in described step 4.5 specifically includes the following steps:
Step 4.5.1, judge that m_fpselected_record for sky, is then exited if it is sky;
Step 4.5.2, MapViewOfFile is called, by corresponding file by the file on hard disk according to every time by m_ AllocationGranularity size is mapped in memory pointer mapH;
Step 4.5.3, the m_ for calling DealWithLogItemRecord processing MapViewOfFile to read out The data block of AllocationGranularity byte-sized;
Step 4.5.4, judge whether to reach end of file, if reached, exit the program;Step is transferred to if not 4.5.2, next data block of file is read.
5. a kind of method that display interlocking log is read based on Windows file mapping technology according to claim 4, Be characterized in that, in the step 4.5.3 call DealWithLogItemRecord function specifically includes the following steps:
Step 4.5.3.1, determine whether the character stream of input is the initial data block of the journal file, if it is not, will input Data flow to ‘ r ', and ' n ' and data content before copy in the character array tailcontent that previous piece stays, and make Tailcontent becomes a complete record, and call MatchStrInStr and ParseFilterContentRecord into Row deletes choosing;
Step 4.5.3.2, untreated byte subscript is recorded as index;
Step 4.5.3.3, it from i-th ndex byte poll backward, often encounters ' r " n ' and is then recorded as a complete record;
Step 4.5.3.4, judge whether it is completely to record, if it is not, then by remaining content assignment to tailcontent In;
Step 4.5.3.5, determine whether keyword is empty in search condition, if it is not, MatchStrInStr is called to reject not Log recording comprising this keyword;
Step 4.5.3.6, it calls ParseFilterContentRecord to delete by type and selects qualified log recording;
Step 4.5.3.7, whether end of file is reached, if it is, exiting;
Step 4.5.3.8, step step 4.5.3.3 is gone to.
6. a kind of method that display interlocking log is read based on Windows file mapping technology according to claim 5, Be characterized in that, in the step 4.5.3.1 call ParseFilterContentRecord carry out parsing specifically include it is following Step:
Step 4.5.3.1.1, the input structure of defined function first:
Step 4.5.3.1.2, index value ind and count value count is initialized;
Step 4.5.3.1.3, ind < contentlen is determined, if so, step 4.5.3.1.4 is executed, if it is not, explanation is It finishes, exits the program through browsing;
Step 4.5.3.1.4, then determine tailcontent [ind]!=' * ', if it is, ind++, is transferred to step 4.5.3.1.2 if it is not, then executing step 4.5.3.1.5;
Step 4.5.3.1.5, then determine whether count can filter out the particular value of record type, if so, executing step 4.5.3.1.7 if it is not, executing step 4.5.3.1.6;
Step 4.5.3.1.6, then count++, ind+=3, and it is transferred to step 4.5.3.1.2;
Step 4.5.3.1.7, record type value is extracted from record to typecur and is compared fortune with type It calculates;
Step 4.5.3.1.8, judge whether typecur meets type and delete choosing requirement, if it is not, then return -1, exits the program, If so, executing step 4.5.3.1.9;
Step 4.5.3.1.9, then Fileindex, mpa_data_offset, tailoffset are recorded In recordonly.dat.
7. a kind of method that display interlocking log is read based on Windows file mapping technology according to claim 6, It is characterized in that, the input structure of the defined function specifically:
char*tailcontent;The beginning of // a line log,
DWORD contentlen;The length of // a line log,
DWORD mpa_data_offset;// this row log is located at which blocks of files of the journal file,
DWORD tailoffset;// this row log be located at this document block which oneself start,
FILE*fp;The file pointer of //recordonly.dat,
ULONG type;The searching class offset of // input,
USHORT fileindex;// log is located at which file in file.
8. a kind of method that display interlocking log is read based on Windows file mapping technology according to claim 6, It is characterized in that, needs journal entries to be shown to specifically include by index file recordonly.dat file quick obtaining following Step:
Step 9.1 will need record subscript index value iItemIndx to be shown as input first;
The initial address for m_fpselected being moved on to the section that needs are read is calculated according to iItemIndx for step 9.2;
Step 9.3 reads Fileindex, map_data_offset and tail_ from m_fpselected_record offset;
Step 9.4, from file pointer array m_mapFileH_Month [] and file size array m_FileSize_Month [] In be fetched into corresponding file pointer mapfilehandle and file size FileSize;
Step 9.5 calls MapViewOfFile that the content in journal file is mapped directly to character string pointer m_mapH;
Whether the content in step 9.6, inspection this part map_data_offset and offset tail_offset reads enough is worked as It moves ahead, i.e. this log end for being exactly the record block, it is complete either with or without reading, if it does, being then transferred to step 9.7, if not, then it is transferred to step 9.8;
Step 9.7 calls GetLine1 and wherein will be transferred to step 9.10 into prec by Context resolution;
Step 9.8 is read under file data by the incomplete data backup of this block of tail portion, and using MapViewOfFile One piece, then by next piece of header contents assignment of reading to the front of previous piece of tail data, form a complete data Record;
Step 9.9, call GetLine2 and will wherein Context resolution into prec;
Step 9.10 exits the program.
9. a kind of method that display interlocking log is read based on Windows file mapping technology according to claim 1, It is characterized in that, the method further include:
Step 8, the search method for other searching requirements, type delete choosing, and character string includes to double-click certain cell to show this Column are entirely and double-click the identical content of cell, wait the algorithm of any original search condition of modification, are both needed to define search condition Afterwards, then S4 is gone to step, regenerates index file recordonly.dat.
CN201810691686.1A 2018-06-28 2018-06-28 Method for reading and displaying interlocking log based on Windows file mapping technology Active CN108959527B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810691686.1A CN108959527B (en) 2018-06-28 2018-06-28 Method for reading and displaying interlocking log based on Windows file mapping technology

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810691686.1A CN108959527B (en) 2018-06-28 2018-06-28 Method for reading and displaying interlocking log based on Windows file mapping technology

Publications (2)

Publication Number Publication Date
CN108959527A true CN108959527A (en) 2018-12-07
CN108959527B CN108959527B (en) 2023-06-09

Family

ID=64488047

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810691686.1A Active CN108959527B (en) 2018-06-28 2018-06-28 Method for reading and displaying interlocking log based on Windows file mapping technology

Country Status (1)

Country Link
CN (1) CN108959527B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112346716A (en) * 2020-11-20 2021-02-09 卡斯柯信号(成都)有限公司 JavaScript-based Web site playback function development framework
CN112597228A (en) * 2020-12-26 2021-04-02 中国农业银行股份有限公司 File processing method and system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102509137A (en) * 2011-11-18 2012-06-20 上海佳依佳信息科技有限公司 Hazardous material logistics intelligent monitoring system
CN103500173A (en) * 2013-09-03 2014-01-08 北京泰乐德信息技术有限公司 Method for inquiring rail transit monitoring data
CN107818282A (en) * 2017-09-30 2018-03-20 努比亚技术有限公司 Two-dimensional code identification method, terminal and computer-readable recording medium
CN108170727A (en) * 2017-12-12 2018-06-15 交控科技股份有限公司 A kind of automatic processing method and device for interlocking data

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102509137A (en) * 2011-11-18 2012-06-20 上海佳依佳信息科技有限公司 Hazardous material logistics intelligent monitoring system
CN103500173A (en) * 2013-09-03 2014-01-08 北京泰乐德信息技术有限公司 Method for inquiring rail transit monitoring data
CN107818282A (en) * 2017-09-30 2018-03-20 努比亚技术有限公司 Two-dimensional code identification method, terminal and computer-readable recording medium
CN108170727A (en) * 2017-12-12 2018-06-15 交控科技股份有限公司 A kind of automatic processing method and device for interlocking data

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112346716A (en) * 2020-11-20 2021-02-09 卡斯柯信号(成都)有限公司 JavaScript-based Web site playback function development framework
CN112346716B (en) * 2020-11-20 2023-08-25 卡斯柯信号(成都)有限公司 Web station playback function development framework based on JavaScript
CN112597228A (en) * 2020-12-26 2021-04-02 中国农业银行股份有限公司 File processing method and system

Also Published As

Publication number Publication date
CN108959527B (en) 2023-06-09

Similar Documents

Publication Publication Date Title
Hopgood et al. Introduction to the Graphical Kernel System (GKS)(revised for international standard)
US11556697B2 (en) Intelligent text annotation
US8418053B2 (en) Division program, combination program and information processing method
US7617444B2 (en) File formats, methods, and computer program products for representing workbooks
CN101894065B (en) System and method for demonstrating the correctness of an execution trace in concurrent processing environments
US20050108189A1 (en) System and method for building a large index
US9182947B2 (en) Program source code navigation
US8572062B2 (en) Indexing documents using internal index sets
CN109471851A (en) Data processing method, device, server and storage medium
CN108959527A (en) The method for reading display interlocking log based on Windows file mapping technology
CN115408247A (en) Threat behavior analysis method based on big data and server
US8489537B2 (en) Segmenting sequential data with a finite state machine
JP5687813B2 (en) Multimedia data publishing system
CN101295312B (en) Method for presenting data by table
Diez qd-Build your own LS-DYNA Tool Quickly in Python
CN108089973A (en) A kind of information processing method and equipment
Shi et al. Video Preview Generation for Interactive Educational Digital Resources Based on the GUI Traversal.
CN113010400B (en) Computer processing technology document intelligent generation and multiple disk system and method
CN110569430A (en) mobile terminal web crawler system
CN117931608A (en) Method and device for counting file cache occupation in vmcore and storage medium
US8972335B2 (en) Method and system for extracting information from electronic data sources
Hazel Development of the ZED text editor
JP2007114972A (en) Data processing method of structured document, data processing program and data processor
CN109710305A (en) A kind of acquisition methods, device, storage medium and terminal device for developing information
CN117216090A (en) Data analysis method, device, computer equipment and storage medium thereof

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant