% ------------------------------------------------------------------------------
% Print technical message data in output CSV file.
%
% SYNTAX :
%  print_tech_data_in_csv_1_3_11_12_17_24_31(a_tabTech, ...
%    a_floatTimeParts, a_utcTimeJuld, a_floatClockDrift, a_decoderId)
%
% INPUT PARAMETERS :
%   a_tabTech         : decoded technical data
%   a_floatTimeParts  : float time
%   a_utcTimeJuld     : satellite time
%   a_floatClockDrift : float clock drift
%   a_decoderId       : float decoder Id
%
% OUTPUT PARAMETERS :
%
% EXAMPLES :
%
% SEE ALSO :
% AUTHORS  : Jean-Philippe Rannou (Altran)(jean-philippe.rannou@altran.com)
% ------------------------------------------------------------------------------
% RELEASES :
%   01/02/2010 - RNU - creation
% ------------------------------------------------------------------------------
function print_tech_data_in_csv_1_3_11_12_17_24_31(a_tabTech, ...
   a_floatTimeParts, a_utcTimeJuld, a_floatClockDrift, a_decoderId)

% current float WMO number
global g_decArgo_floatNum;

% current cycle number
global g_decArgo_cycleNum;

% output CSV file Id
global g_decArgo_outputCsvFileId;

fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; TECHNICAL MESSAGE CONTENTS\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum);

fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; descent start time; %d; =>; %s\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(1), format_time_dec_argo(a_tabTech(1)*6/60));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of valve actions at the surface; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(2));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; float stabilisation time; %d; =>; %s\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(3), format_time_dec_argo(a_tabTech(3)*6/60));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; float stabilisation pressure; %d; dbar\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(4));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of valve actions in descent; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(5));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of pump actions in descent; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(6));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; end of descent time; %d; =>; %s\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(7), format_time_dec_argo(a_tabTech(7)*6/60));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of repositions; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(8));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; time at end of ascent; %d; =>; %s\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(9), format_time_dec_argo(a_tabTech(9)*6/60));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of pump actions in ascent; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(10));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of descent CTD messages; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(11));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of drift CTD messages; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(12));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of ascent CTD messages; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(13));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of descent slices in shallow zone; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(14));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of descent slices in deep zone; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(15));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of ascent slices in shallow zone; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(16));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of ascent slices in deep zone; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(17));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of CTD measurements in drift; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(18));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; float''s time : hh (5bits)+mm (6bits)+ss (6bits); %d; =>; %02d:%02d:%02d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(19), a_floatTimeParts(1), a_floatTimeParts(2), a_floatTimeParts(3));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; satellite reception time of technical message; %s\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, julian_2_gregorian_dec_argo(a_utcTimeJuld));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; = > float clock drift; %s\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, format_time_dec_argo(a_floatClockDrift*24));

% floatClockDrift = round(a_floatClockDrift*1440)/1440;
% fprintf('@#@ float %d : @ cycle %d @ date %s @ clock drift %s @ final correction\n', ...
%    g_decArgo_floatNum, g_decArgo_cycleNum, julian_2_gregorian_dec_argo(a_utcTimeJuld), format_time_dec_argo(floatClockDrift*24));

fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; pressure sensor offset; %.1f; dbar\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(20));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; internal pressure; %d; =>; %s\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(21), decode_internal_pressure(a_tabTech(21)));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; max pressure in descent to parking depth; %d; dbar\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(22));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; profile ascent start time; %d; =>; %s\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(23), format_time_dec_argo(a_tabTech(23)*6/60));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of entrance in drift target range (descent); %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(24));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; minimum pressure in drift (bars); %d; dbar\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(25));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; maximum pressure in drift (bars); %d; dbar\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(26));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; grounding detected (grounding = 1, No grounding = 0); %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(27));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of hydraulic valve action in descent profile; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(28));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of pump actions in descent profile; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(29));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; max pressure in descent or drift to Pprofile (bars); %d; dbar\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(30));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of re-positioning in profile stand-by; %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(31));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; batteries voltage drop at Pmax, pump ON (with regard to Unom = 10.0 V) (in dV); %d; =>; %.1f; V\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(32), 10-(a_tabTech(32)/10));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; profile descent start time; %d; =>; %s\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(33), format_time_dec_argo(a_tabTech(33)*6/60));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; profile descent stop time; %d; =>; %s\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(34), format_time_dec_argo(a_tabTech(34)*6/60));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; RTC state indicator ( normal = 0, failure = 1); %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(35));
fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of entrance in profile target range (descent); %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(36));

if (a_decoderId == 31)
   fprintf(g_decArgo_outputCsvFileId, '%d; %d; Tech; number of pump actions to lift up from ground (res. 5 actions); %d\n', ...
   g_decArgo_floatNum, g_decArgo_cycleNum, a_tabTech(38)*5);
end

return
