% ------------------------------------------------------------------------------
% Print CTD sensor technical data in output CSV file.
%
% SYNTAX :
%  print_sensor_tech_data_in_csv_file_ir_rudics_sbd2_CTD( ...
%    a_cycleNum, a_profNum, a_dataIndexList, ...
%    a_sensorTechCTD)
%
% INPUT PARAMETERS :
%   a_cycleNum      : cycle number of the packet
%   a_profNum       : profile number of the packet
%   a_dataIndex     : index of the packet
%   a_sensorTechCTD : CTD 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_sbd2_CTD( ...
   a_cycleNum, a_profNum, a_dataIndexList, ...
   a_sensorTechCTD)

% current float WMO number
global g_decArgo_floatNum;

% output CSV file Id
global g_decArgo_outputCsvFileId;

% unpack the input data
a_sensorTechCTDNbPackDesc = a_sensorTechCTD{1};
a_sensorTechCTDNbPackDrift = a_sensorTechCTD{2};
a_sensorTechCTDNbPackAsc = a_sensorTechCTD{3};
a_sensorTechCTDNbMeasDescZ1 = a_sensorTechCTD{4};
a_sensorTechCTDNbMeasDescZ2 = a_sensorTechCTD{5};
a_sensorTechCTDNbMeasDescZ3 = a_sensorTechCTD{6};
a_sensorTechCTDNbMeasDescZ4 = a_sensorTechCTD{7};
a_sensorTechCTDNbMeasDescZ5 = a_sensorTechCTD{8};
a_sensorTechCTDNbMeasDrift = a_sensorTechCTD{9};
a_sensorTechCTDNbMeasAscZ1 = a_sensorTechCTD{10};
a_sensorTechCTDNbMeasAscZ2 = a_sensorTechCTD{11};
a_sensorTechCTDNbMeasAscZ3 = a_sensorTechCTD{12};
a_sensorTechCTDNbMeasAscZ4 = a_sensorTechCTD{13};
a_sensorTechCTDNbMeasAscZ5 = a_sensorTechCTD{14};
a_sensorTechCTDSensorState = a_sensorTechCTD{15};
a_sensorTechCTDOffsetPres = a_sensorTechCTD{16};
a_sensorTechCTDSubPres = a_sensorTechCTD{17};
a_sensorTechCTDSubTemp = a_sensorTechCTD{18};
a_sensorTechCTDSubSal = a_sensorTechCTD{19};

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

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

   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb packets for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbPackDesc(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb packets for drift; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbPackDrift(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb packets for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbPackAsc(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb bins in zone 1 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbMeasDescZ1(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb bins in zone 2 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbMeasDescZ2(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb bins in zone 3 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbMeasDescZ3(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb bins in zone 4 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbMeasDescZ4(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb bins in zone 5 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbMeasDescZ5(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb bins for drift; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbMeasDrift(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb bins in zone 1 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbMeasAscZ1(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb bins in zone 2 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbMeasAscZ2(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb bins in zone 3 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbMeasAscZ3(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb bins in zone 4 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbMeasAscZ4(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Nb bins in zone 5 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDNbMeasAscZ5(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Sensor state indicator (1:Ok, 0:Ko); %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDSensorState(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; Pressure offset; %g\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDOffsetPres(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; "Subsurface" P; %g\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDSubPres(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; "Subsurface" T; %g\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDSubTemp(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CTD tech; "Subsurface" S; %g\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCTDSubSal(idP, 3));
end

return
