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

% current float WMO number
global g_decArgo_floatNum;

% output CSV file Id
global g_decArgo_outputCsvFileId;

% unpack the input data
a_sensorTechFLBBNbPackDesc = a_sensorTechFLBB{1};
a_sensorTechFLBBNbPackDrift = a_sensorTechFLBB{2};
a_sensorTechFLBBNbPackAsc = a_sensorTechFLBB{3};
a_sensorTechFLBBNbMeasDescZ1 = a_sensorTechFLBB{4};
a_sensorTechFLBBNbMeasDescZ2 = a_sensorTechFLBB{5};
a_sensorTechFLBBNbMeasDescZ3 = a_sensorTechFLBB{6};
a_sensorTechFLBBNbMeasDescZ4 = a_sensorTechFLBB{7};
a_sensorTechFLBBNbMeasDescZ5 = a_sensorTechFLBB{8};
a_sensorTechFLBBNbMeasDrift = a_sensorTechFLBB{9};
a_sensorTechFLBBNbMeasAscZ1 = a_sensorTechFLBB{10};
a_sensorTechFLBBNbMeasAscZ2 = a_sensorTechFLBB{11};
a_sensorTechFLBBNbMeasAscZ3 = a_sensorTechFLBB{12};
a_sensorTechFLBBNbMeasAscZ4 = a_sensorTechFLBB{13};
a_sensorTechFLBBNbMeasAscZ5 = a_sensorTechFLBB{14};
a_sensorTechFLBBSensorState = a_sensorTechFLBB{15};
a_sensorTechFLBBSensorSerialNum = a_sensorTechFLBB{16};
a_sensorTechFLBBCoefScaleFactChloroA = a_sensorTechFLBB{17};
a_sensorTechFLBBCoefDarkCountChloroA = a_sensorTechFLBB{18};
a_sensorTechFLBBCoefScaleFactBackscat = a_sensorTechFLBB{19};
a_sensorTechFLBBCoefDarkCountBackscat = a_sensorTechFLBB{20};

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

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

   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb packets for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbPackDesc(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb packets for drift; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbPackDrift(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb packets for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbPackAsc(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb bins in zone 1 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbMeasDescZ1(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb bins in zone 2 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbMeasDescZ2(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb bins in zone 3 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbMeasDescZ3(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb bins in zone 4 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbMeasDescZ4(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb bins in zone 5 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbMeasDescZ5(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb bins for drift; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbMeasDrift(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb bins in zone 1 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbMeasAscZ1(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb bins in zone 2 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbMeasAscZ2(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb bins in zone 3 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbMeasAscZ3(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb bins in zone 4 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbMeasAscZ4(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Nb bins in zone 5 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBNbMeasAscZ5(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Sensor state indicator (1:Ok, 0:Ko); %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBSensorState(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; Sensor serial num; %g\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechFLBBSensorSerialNum(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; ScaleFactChloroA; %s\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      num_2_str(a_sensorTechFLBBCoefScaleFactChloroA(idP, 3)));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; DarkCountChloroA; %s\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      num_2_str(a_sensorTechFLBBCoefDarkCountChloroA(idP, 3)));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; ScaleFactBackscatter700; %s\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      num_2_str(a_sensorTechFLBBCoefScaleFactBackscat(idP, 3)));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; FLBB tech; DarkCountBackscatter700; %s\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      num_2_str(a_sensorTechFLBBCoefDarkCountBackscat(idP, 3)));
end

return
