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

% current float WMO number
global g_decArgo_floatNum;

% output CSV file Id
global g_decArgo_outputCsvFileId;

% unpack the input data
a_sensorTechCYCLOPSNbPackDesc = a_sensorTechCYCLOPS{1};
a_sensorTechCYCLOPSNbPackDrift = a_sensorTechCYCLOPS{2};
a_sensorTechCYCLOPSNbPackAsc = a_sensorTechCYCLOPS{3};
a_sensorTechCYCLOPSNbMeasDescZ1 = a_sensorTechCYCLOPS{4};
a_sensorTechCYCLOPSNbMeasDescZ2 = a_sensorTechCYCLOPS{5};
a_sensorTechCYCLOPSNbMeasDescZ3 = a_sensorTechCYCLOPS{6};
a_sensorTechCYCLOPSNbMeasDescZ4 = a_sensorTechCYCLOPS{7};
a_sensorTechCYCLOPSNbMeasDescZ5 = a_sensorTechCYCLOPS{8};
a_sensorTechCYCLOPSNbMeasDrift = a_sensorTechCYCLOPS{9};
a_sensorTechCYCLOPSNbMeasAscZ1 = a_sensorTechCYCLOPS{10};
a_sensorTechCYCLOPSNbMeasAscZ2 = a_sensorTechCYCLOPS{11};
a_sensorTechCYCLOPSNbMeasAscZ3 = a_sensorTechCYCLOPS{12};
a_sensorTechCYCLOPSNbMeasAscZ4 = a_sensorTechCYCLOPS{13};
a_sensorTechCYCLOPSNbMeasAscZ5 = a_sensorTechCYCLOPS{14};
a_sensorTechCYCLOPSSensorState = a_sensorTechCYCLOPS{15};
a_sensorTechCYCLOPSAvgSampMax = a_sensorTechCYCLOPS{16};
a_sensorTechCYCLOPSCalib1Volts = a_sensorTechCYCLOPS{17};
a_sensorTechCYCLOPSCalib1PhysicalValue = a_sensorTechCYCLOPS{18};
a_sensorTechCYCLOPSCalib2Volts = a_sensorTechCYCLOPS{19};
a_sensorTechCYCLOPSCalib2PhysicalValue = a_sensorTechCYCLOPS{20};
a_sensorTechCYCLOPSOpenDrainOutputUsedForSensorGain = a_sensorTechCYCLOPS{21};
a_sensorTechCYCLOPSOpenDrainOutputState = a_sensorTechCYCLOPS{22};

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

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

   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb packets for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbPackDesc(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb packets for drift; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbPackDrift(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb packets for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbPackAsc(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb bins in zone 1 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbMeasDescZ1(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb bins in zone 2 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbMeasDescZ2(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb bins in zone 3 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbMeasDescZ3(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb bins in zone 4 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbMeasDescZ4(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb bins in zone 5 for descent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbMeasDescZ5(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb bins for drift; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbMeasDrift(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb bins in zone 1 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbMeasAscZ1(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb bins in zone 2 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbMeasAscZ2(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb bins in zone 3 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbMeasAscZ3(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb bins in zone 4 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbMeasAscZ4(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Nb bins in zone 5 for ascent; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSNbMeasAscZ5(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Sensor state indicator (1:Ok, 0:Ko); %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSSensorState(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Average sample max; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSAvgSampMax(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Calib point #1: ADC value; %g\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSCalib1Volts(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Calib point #1: physical value; %g\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSCalib1PhysicalValue(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Calib point #2: ADC value; %g\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSCalib2Volts(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Calib point #2: physical value; %g\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSCalib2PhysicalValue(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Open drain output used for sensor gain; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSOpenDrainOutputUsedForSensorGain(idP, 3));
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; %d; %s; CYCLOPS tech; Open drain output state; %d\n', ...
      g_decArgo_floatNum, a_cycleNum, a_profNum, get_phase_name(-1), ...
      a_sensorTechCYCLOPSOpenDrainOutputState(idP, 3));
end

return
