%
% PURPOSE : Read test results file for One-View Visualization (OVV) diagram displaying mobile
% phone speech quality measurements, according to ITU-T P505 standard
%
% FUNCTION CALL : [s_use_case, d_test_cases, s_aqi_version, s_platform, t_fta_results] =...
% f_ovv1x_read(s_file_name_in, d_disp_flag)
%
% FUNCTION ARGUMENTS :
%
% s_file_name_in : (optional), input file name (*.txt, *.dat)
% d_disp_flag : (optional), display information on cmd window, 1 (default)= display,
% 0 = no display
% s_use_case : name of use case (handset, headset, handsfree,...)
% d_test_cases : number of tests
% s_aqi_version : version of tested system
% s_platform : name of real-time/simulation platform
% t_fta_results : structure of FTA tests names + values
%
%*******************************************************************************************
% COMPANY NAME : Homework
%
% FILE NAME : f_ovv1x_read.m
%
% AUTHOR : Thierry Le Gall - Digital Communications, Audio & Acoustic Engineer
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ------------- ------------- ------- ------------------------------------------------
% Sep. 11, 2009 T. Le Gall 0.1 Creation
% Sep. 14, 2009 T. Le Gall 0.2 Update : User pressed cancel
%
% NOTES :
%
% Custom functions used :
%
% - f_ovv1x_get_header()
% - f_ovv1x_get_test()
%
%*****************************************************************************************
function [s_use_case, d_test_cases, s_aqi_version, s_platform, t_fta_results] =...
f_ovv1x_read(s_file_name_in, d_disp_flag)
global t_ovv1x_static_var; %#ok<NUSED>
global t_ovv1x_gui_param;
global s_ovv1x_path_name_in;
S_CURRENT_DIR = pwd;
C_DISP_FLAG_DEFAULT = 1;
if (nargin < 2)
d_disp_flag = C_DISP_FLAG_DEFAULT;
end
s_ovv1x_path_name_in = t_ovv1x_gui_param.s_ovv1x_tool_database_path;
% ** Get Input File **
if (nargin == 0)% Data from File Trough GUI
if (and((~isempty(s_ovv1x_path_name_in)), (s_ovv1x_path_name_in ~= 0)))
cd(s_ovv1x_path_name_in); % GUI to same location as previous file
end
s_dialog_box_in = 'Load FTA Test File';
[s_file_name_in, s_path_name_in] = uigetfile('*.dat;*.txt', s_dialog_box_in);
if isequal(s_file_name_in, 0) || isequal(s_path_name_in, 0)
disp('User pressed cancel')
s_use_case = '';
d_test_cases = 0;
s_aqi_version = '';
s_platform = '';
t_fta_results = 0;
cd(S_CURRENT_DIR);
return;
else
s_input_file_name = strcat(s_path_name_in, s_file_name_in);
s_ovv1x_path_name_in = s_path_name_in;
cd(S_CURRENT_DIR);
end
else
s_input_file_name = s_file_name_in;
end
% ** Input File ID an Opening Control **
d_input_fid = fopen(s_input_file_name, 'rt');
if (d_input_fid < 3)
errordlg(['Fail to open FTA results file: ', s_input_file_name]);
return;
end
if (d_disp_flag)
disp('--> OVV READ FILE START')
end
% ** Import header data **
s_aqi_version = f_ovv1x_get_header(fgetl(d_input_fid), '=');
s_platform = f_ovv1x_get_header(fgetl(d_input_fid), '=');
s_use_case = f_ovv1x_get_header(fgetl(d_input_fid), '=');
d_test_cases = str2double(f_ovv1x_get_header(fgetl(d_input_fid), '='));
% ** Import tests results **
switch upper(s_use_case)
case {t_ovv1x_static_var.S_USE_CASE_HANDSET,...
t_ovv1x_static_var.S_USE_CASE_HEADSET,...
t_ovv1x_static_var.S_USE_CASE_HANDSFREE}
for d_counter = 1:d_test_cases
[t_fta_results.test(d_counter).s_name,...
t_fta_results.test(d_counter).s_value,...
t_fta_results.test(d_counter).s_unit] = f_ovv1x_get_test(fgetl(d_input_fid), '=');
end
otherwise
errordlg({['Unsupported test case: ', s_use_case]; ['Check file: ', s_file_name_in]});
end
fclose(d_input_fid);
if (d_disp_flag)
disp(' OVV READ FILE END <--')
end
return;
function [s_test_name, s_test_result, s_test_unit] = f_ovv1x_get_test(s_line, s_symbol)
% ** Get test name **
s_test_name = s_line(min(findstr('-', s_line))+1:min(findstr(s_symbol, s_line))-1);
if ~isempty(s_test_name) % remove tabs if any
while (s_test_name(1) == ' ')
s_test_name = s_test_name(2:end);
end
while (s_test_name(end) == ' ')
s_test_name = s_test_name(1:end-1);
end
end
% ** Get test result **
s_test_result_unit = s_line(max(findstr(s_symbol, s_line))+1:end);
if ~isempty(s_test_result_unit) % remove tabs if any
while (s_test_result_unit(1) == ' ')
s_test_result_unit = s_test_result_unit(2:end);
end
while (s_test_result_unit(end) == ' ')
s_test_result_unit = s_test_result_unit(1:end-1);
end
end
% ** Get test unit if any
if ~isempty(findstr(s_test_result_unit, ' '))
s_test_result = s_test_result_unit(1:findstr(s_test_result_unit, ' ')-1);
s_test_unit = s_test_result_unit(findstr(s_test_result_unit, ' ')+1:end);
else
s_test_result = s_test_result_unit;
s_test_unit = '';
end
return;
function [s_test_header] = f_ovv1x_get_header(s_line, s_symbol)
% ** Get header line **
s_test_header = s_line(max(findstr(s_symbol, s_line))+1:end);
if ~isempty(s_test_header) % remove tabs if any
while (s_test_header(1) == ' ')
s_test_header = s_test_header(2:end);
end
while (s_test_header(end) == ' ')
s_test_header = s_test_header(1:end-1);
end
end
return;