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

% current float WMO number
global g_decArgo_floatNum;

% output CSV file Id
global g_decArgo_outputCsvFileId;

% unpack the input data
a_sensorTechECO2NbPackDesc = a_sensorTechECO2{1};
a_sensorTechECO2NbPackDrift = a_sensorTechECO2{2};
a_sensorTechECO2NbPackAsc = a_sensorTechECO2{3};
a_sensorTechECO2NbMeasDescZ1 = a_sensorTechECO2{4};
a_sensorTechECO2NbMeasDescZ2 = a_sensorTechECO2{5};
a_sensorTechECO2NbMeasDescZ3 = a_sensorTechECO2{6};
a_sensorTechECO2NbMeasDescZ4 = a_sensorTechECO2{7};
a_sensorTechECO2NbMeasDescZ5 = a_sensorTechECO2{8};
a_sensorTechECO2NbMeasDrift = a_sensorTechECO2{9};
a_sensorTechECO2NbMeasAscZ1 = a_sensorTechECO2{10};
a_sensorTechECO2NbMeasAscZ2 = a_sensorTechECO2{11};
a_sensorTechECO2NbMeasAscZ3 = a_sensorTechECO2{12};
a_sensorTechECO2NbMeasAscZ4 = a_sensorTechECO2{13};
a_sensorTechECO2NbMeasAscZ5 = a_sensorTechECO2{14};
a_sensorTechECO2SensorState = a_sensorTechECO2{15};
a_sensorTechECO2SensorSerialNum = a_sensorTechECO2{16};
a_sensorTechECO2CoefScaleFactChloroA = a_sensorTechECO2{17};
a_sensorTechECO2CoefDarkCountChloroA = a_sensorTechECO2{18};
a_sensorTechECO2CoefScaleFactBackscat = a_sensorTechECO2{19};
a_sensorTechECO2CoefDarkCountBackscat = a_sensorTechECO2{20};

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

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

   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb packets for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbPackDesc(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb packets for drift; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbPackDrift(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb packets for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbPackAsc(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb bins in zone 1 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbMeasDescZ1(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb bins in zone 2 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbMeasDescZ2(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb bins in zone 3 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbMeasDescZ3(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb bins in zone 4 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbMeasDescZ4(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb bins in zone 5 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbMeasDescZ5(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb bins for drift; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbMeasDrift(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb bins in zone 1 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbMeasAscZ1(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb bins in zone 2 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbMeasAscZ2(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb bins in zone 3 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbMeasAscZ3(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb bins in zone 4 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbMeasAscZ4(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Nb bins in zone 5 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2NbMeasAscZ5(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Sensor state indicator (1:Ok, 0:Ko); %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2SensorState(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; Sensor serial num; %g\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechECO2SensorSerialNum(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; ScaleFactChloroA; %s\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      num_2_str(a_sensorTechECO2CoefScaleFactChloroA(idP, 3)));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; DarkCountChloroA; %s\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      num_2_str(a_sensorTechECO2CoefDarkCountChloroA(idP, 3)));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; ScaleFactBackscatter700; %s\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      num_2_str(a_sensorTechECO2CoefScaleFactBackscat(idP, 3)));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; ECO2 tech; DarkCountBackscatter700; %s\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      num_2_str(a_sensorTechECO2CoefDarkCountBackscat(idP, 3)));
end

return
