%% Read and Analyse data from VNA, PNA and SPA used for the course

%% --- Read from HP8753 and PNA vector Analysers, HP Spectrum Anal., Rohde Spectrum Analysers---
% The following commands result in a dataStruct struct in the Matlab WorkSpace
% BoardNumber = 0;        % The GPIB controller card number
% BoardNumber = 1;        % The USB-GPIB controller card number
% BoardNumber = 2;        % The USB-GPIB controller card number for ZND
                          % Vector Analyser

% DeviceNumber = 8;       % HP VNA device number (VNA1)
% DeviceNumber = 10;      % Agilent VNA device number (VNA2)
% DeviceNumber = 16;      % Agilent PNA device number (PNA) and VNA3 HP8753B

% DeviceNumber = 18;      % Spectrum Analyser device number (Rohde or HP)
% DeviceNumber = 20;      % Spectrum Analyser device number (Rohde or HP) and ZND Vector Analyser


%  IPaddress='151.100.44.73';  %FieldFox Network Analyzer
% IPaddress='151.100.44.28';  %ZVL Network Analyzer (not anymore avaiable)



%%% read the data struct from the instrument VNA or PNA
% dataStruct=getdataNAv2(BoardNumber,DeviceNumber);    % for VNA1, VNA2, VNA3, ZND
%%%% For PNA
%%% Single trace
%dataStruct=getdataPNAv3(BoardNumber,DeviceNumber);   % for PNA
%%% Multiple Traces
%NTr=2; %Trace number of the desired measure (Read the PNA display) 
%dataStruct=getdataPNAv3(BoardNumber,DeviceNumber,NTr);   % for PNA
%%%%%%%%%
% dataStruct=getdataZVLNA(IPaddress);                  % for ZVL Rohde & Schwarz NA
% dataStruct=getdataFFPNA(IPaddress);                  % for Agilent FieldFox NA

% dataStruct=getdataHPSPA(BoardNumber,DeviceNumber);   % for Spectrum Analysers (HP)
% dataStruct=getdataRSSPA(BoardNumber,DeviceNumber);   % for Spectrum Analysers (Rohde)
%  dataStruct=getdataFFSPA(IPaddress);                  % for Agilent FieldFox SPA

%%% End of Data Struct reading
%% --------- End of HP8753 and PNA commands ----

%% ---- Read data file for Rohde & Schwarz SPA when using USB pen drive -----
% The following commands result in a dataStruct struct in the Matlab WorkSpace
% Used in the acquisition from ZVL Spectrum Analyser

% Choose the datafile to be read
% [filename, pathname, filterindex] = uigetfile('*.txt;*.TXT;*.DAT;*.dat;', 'Pick a SPA data file');
% dataFile=[pathname filename];
% 
% dataStruct=getdataRohdeSPA(dataFile);
%% ------ End of Rohde & Schwarz SPA commands when using USB pen drive -------

%% ---- Read data file for Agilent Field Fox Spectrum Analyser -------
% Routine usable also for Agilent Field Fox Network Analyser by saving sXp files
% The following commands result in a dataStruct in the Matlab WorkSpace is
% reading a .csv file, while in a Spramenters struct if reading a sXp file.

% [filename, pathname, filterindex] = uigetfile('*.csv;*.s2p;*.s1p', 'Pick a Field Fox data file');
% dataFile=[pathname filename];
% if strfind(dataFile,'.csv'),
%     dataStruct=getdataFieldFoxCSV(dataFile);
% elseif strfind(dataFile,'.s2p'),
%     Sparameters=DatareadS2p(dataFile);
% elseif strfind(dataFile,'.s1p'),
%     Sparameters=DatareadS1p(dataFile);
% end
%% ---- End of Agilent Field Fox commands -------