% ------------------------------------------------------------------------------
% Print SUNA sensor technical data in output CSV file.
%
% SYNTAX :
%  print_sensor_tech_data_in_csv_file_ir_rudics_SUNA( ...
%    a_cycleNum, a_profNum, a_dataIndexList, ...
%    a_sensorTechSUNA)
%
% INPUT PARAMETERS :
%   a_cycleNum       : cycle number of the packet
%   a_profNum        : profile number of the packet
%   a_dataIndex      : index of the packet
%   a_sensorTechSUNA : SUNA technical data
%
% OUTPUT PARAMETERS :
%
% EXAMPLES :
%
% SEE ALSO :
% AUTHORS  : Jean-Philippe Rannou (Altran)(jean-philippe.rannou@altran.com)
% ------------------------------------------------------------------------------
% RELEASES :
%   02/11/2013 - RNU - creation
% ------------------------------------------------------------------------------
function print_sensor_tech_data_in_csv_file_ir_rudics_SUNA( ...
   a_cycleNum, a_profNum, a_dataIndexList, ...
   a_sensorTechSUNA)

% current float WMO number
global g_decArgo_floatNum;

% output CSV file Id
global g_decArgo_outputCsvFileId;

% unpack the input data
a_sensorTechSUNANbPackDesc = a_sensorTechSUNA{1};
a_sensorTechSUNANbPackDrift = a_sensorTechSUNA{2};
a_sensorTechSUNANbPackAsc = a_sensorTechSUNA{3};
a_sensorTechSUNANbMeasDescZ1 = a_sensorTechSUNA{4};
a_sensorTechSUNANbMeasDescZ2 = a_sensorTechSUNA{5};
a_sensorTechSUNANbMeasDescZ3 = a_sensorTechSUNA{6};
a_sensorTechSUNANbMeasDescZ4 = a_sensorTechSUNA{7};
a_sensorTechSUNANbMeasDescZ5 = a_sensorTechSUNA{8};
a_sensorTechSUNANbMeasDrift = a_sensorTechSUNA{9};
a_sensorTechSUNANbMeasAscZ1 = a_sensorTechSUNA{10};
a_sensorTechSUNANbMeasAscZ2 = a_sensorTechSUNA{11};
a_sensorTechSUNANbMeasAscZ3 = a_sensorTechSUNA{12};
a_sensorTechSUNANbMeasAscZ4 = a_sensorTechSUNA{13};
a_sensorTechSUNANbMeasAscZ5 = a_sensorTechSUNA{14};
a_sensorTechSUNASensorState = a_sensorTechSUNA{15};
a_sensorTechSUNASensorSerialNum = a_sensorTechSUNA{16};
a_sensorTechSUNAAPFSampCounter = a_sensorTechSUNA{17};
a_sensorTechSUNAAPFPowerCycleCounter = a_sensorTechSUNA{18};
a_sensorTechSUNAAPFErrorCounter = a_sensorTechSUNA{19};
a_sensorTechSUNAAPFSupplyVoltage = a_sensorTechSUNA{20};
a_sensorTechSUNAAPFSupplyCurrent = a_sensorTechSUNA{21};
a_sensorTechSUNAAPFOutPixelBegin = a_sensorTechSUNA{22};
a_sensorTechSUNAAPFOutPixelEnd = a_sensorTechSUNA{23};

% select the data (according to a_cycleNum and a_profNum)
idPack = find((a_sensorTechSUNANbPackDesc(a_dataIndexList, 1) == a_cycleNum) & ...
   (a_sensorTechSUNANbPackDesc(a_dataIndexList, 2) == a_profNum));

for id = 1:length(idPack)
   idP = a_dataIndexList(idPack(id));

   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb packets for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbPackDesc(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb packets for drift; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbPackDrift(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb packets for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbPackAsc(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb bins in zone 1 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbMeasDescZ1(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb bins in zone 2 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbMeasDescZ2(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb bins in zone 3 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbMeasDescZ3(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb bins in zone 4 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbMeasDescZ4(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb bins in zone 5 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbMeasDescZ5(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb bins for drift; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbMeasDrift(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb bins in zone 1 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbMeasAscZ1(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb bins in zone 2 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbMeasAscZ2(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb bins in zone 3 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbMeasAscZ3(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb bins in zone 4 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbMeasAscZ4(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Nb bins in zone 5 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNANbMeasAscZ5(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Sensor state indicator (1:Ok, 0:Ko); %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNASensorState(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; Sensor serial num; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNASensorSerialNum(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; APF: sample counter; %f\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNAAPFSampCounter(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; APF: power cycle counter; %f\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNAAPFPowerCycleCounter(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; APF: error counter; %f\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNAAPFErrorCounter(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; APF: supply voltage; %f\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNAAPFSupplyVoltage(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; APF: supply current; %f\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNAAPFSupplyCurrent(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; APF: output pixel begin; %g\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNAAPFOutPixelBegin(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; SUNA tech; APF: output pixel end; %g\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechSUNAAPFOutPixelEnd(idP, 3));
end

return
