www.pudn.com > GNSS_SDR.zip > postProcessing.m, change:2010-12-02,size:6514b

% Script postProcessing.m processes the raw signal from the specified data 
% file (in settings) operating on blocks of 37 seconds of data. 
% First it runs acquisition code identifying the satellites in the file, 
% then the code and carrier for each of the satellites are tracked, storing 
% the 1msec accumulations.  After processing all satellites in the 37 sec 
% data block, then postNavigation is called. It calculates pseudoranges 
% and attempts a position solutions. At the end plots are made for that 
% block of data. 
% 本函数对中频原始数据进行处理。首先进行捕获确认可见星,然后对每颗卫星的码和载波 
% 进行跟踪(跟踪周期为1ms)。处理完37秒数据后,调用'postNavigation'计算伪距和定 
% 位结果并绘图表示。 
%                           SoftGNSS v3.0 
% Copyright (C) Darius Plausinaitis 
% Written by Darius Plausinaitis, Dennis M. Akos 
% Some ideas by Dennis M. Akos 
% 注释翻译:苗剑峰 
%This program is free software; you can redistribute it and/or 
%modify it under the terms of the GNU General Public License 
%as published by the Free Software Foundation; either version 2 
%of the License, or (at your option) any later version. 
%This program is distributed in the hope that it will be useful, 
%but WITHOUT ANY WARRANTY; without even the implied warranty of 
%GNU General Public License for more details. 
%You should have received a copy of the GNU General Public License 
%along with this program; if not, write to the Free Software 
%Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
%                         THE SCRIPT "RECIPE" 
% The purpose of this script is to combine all parts of the software 
% receiver. 
% 1.1) Open the data file for the processing and seek to desired point. 
% 2.1) Acquire satellites 
% 3.1) Initialize channels (preRun.m). 
% 3.2) Pass the channel structure and the file identifier to the tracking 
% function. It will read and process the data. The tracking results are 
% stored in the trackResults structure. The results can be accessed this 
% way (the results are stored each millisecond): 
% trackResults(channelNumber).XXX(fromMillisecond : toMillisecond), where 
% XXX is a field name of the result (e.g. I_P, codePhase etc.) 
% 4) Pass tracking results to the navigation solution function. It will 
% decode navigation messages, find satellite positions, measure 
% pseudoranges and find receiver position. 
% 5) Plot the results. 
%% Initialization 初始化 =================================================== 
disp ('开始运行...'); 
[fid, message] = fopen(settings.fileName, 'rb'); 
% If success, then process the data 
% 文件读取成功,开始处理数据 
if (fid > 0) 
    % Move the starting point of processing. Can be used to start the 
    % signal processing at any point in the data record (e.g. good for long 
    % records or for signal processing in blocks). 
    % 跳过开头 
    fseek(fid, settings.skipNumberOfBytes, 'bof'); 
%% Acquisition 捕获 ======================================================== 
    % Do acquisition if it is not disabled in settings or if the variable 
    % acqResults does not exist. 
    % 如果没有设置跳过捕获或者变量'acqResults'不存在 
    if ((settings.skipAcquisition == 0) || ~exist('acqResults', 'var')) 
        % Find number of samples per spreading code 
        % 每个码长对应的采样点数量 
        samplesPerCode = round(settings.samplingFreq / ... 
                           (settings.codeFreqBasis / settings.codeLength)); 
        % Read data for acquisition. 11ms of signal are needed for the fine 
        % frequency estimation 
        % 读入捕获所需数据 11ms 
        data = fread(fid, 11*samplesPerCode, settings.dataType)'; 
        %--- Do the acquisition 开始捕获 ----------------------------------- 
        disp ('开始捕获...'); 
        acqResults = acquisition(data, settings); 
%% Initialize channels and prepare for the run 初始化跟踪通道 ============== 
    % Start further processing only if a GNSS signal was acquired (the 
    % field FREQUENCY will be set to 0 for all not acquired signals) 
    % 开始跟踪(未被捕获的卫星频率清零) 
    if (any(acqResults.carrFreq))   % any为库函数,判断是否为真 
        channel = preRun(acqResults, settings); % preRun在include中 
        showChannelStatus(channel, settings);   % 在include中 
        % No satellites to track, exit 
        % 没有卫星跟踪,退出 
        trackResults = []; 
%% Track the signal 跟踪 ================================================== 
    startTime = now;    % now为系统参数,获得当前时间的数字串(日期和时间) 
    disp (['跟踪开始时间:', datestr(startTime)]); % datestr为库函数,将数字串翻译为 DD-MM-YYYY hh:mm:ss 格式 
    % Process all channels for given data block 
    % 跟踪所有已建立的通道 
    [trackResults, channel] = tracking(fid, channel, settings); 
    % Close the data file 
    % 关闭文件 
    disp(['跟踪结束时间:', ... 
                                        datestr(now - startTime, 13)])      
    % Auto save the acquisition & tracking results to a file to allow 
    % running the positioning solution afterwards. 
    % 保持捕获和跟踪结果到文件 
    save('trackingResults', ... 
                      'trackResults', 'settings', 'acqResults', 'channel');                   
%% Calculate navigation solutions 导航解算 ================================= 
    navSolutions = postNavigation(trackResults, settings); 
%% Plot all results 绘制导航结果============================================ 
    disp ('绘制跟踪结果...'); 
    if settings.plotTracking 
        plotTracking(1:settings.numberOfChannels, trackResults, settings); 
    plotNavigation(navSolutions, settings); 
    % Error while opening the data file. 
    error('无法读取文件%s: %s.', settings.fileName, message); 
end % if (fid > 0)