diff --git a/@tsg_nc/save.m b/@tsg_nc/save.m index 017069337c30143b27b5c914144eeb52c79510f3..61a16751848c301b2204fdffc0f18d0107925263 100644 --- a/@tsg_nc/save.m +++ b/@tsg_nc/save.m @@ -7,6 +7,8 @@ function result = save(self) % return filename % --------------- +global VERSION; + % Open the file % ------------- fid = fopen( self.file, 'wt' ); @@ -22,8 +24,10 @@ nb = numel(key); % Write the date and time when the file is saved % ---------------------------------------------- -fprintf( fid, '%% tsg_platform.csv: %d members & %d lines with data\n',... - self.members, self.size) ; +% TODOS: a changer, le nom tsg_platform ne doit pas etre en dur !!!!! +% +fprintf( fid, '%% tsg_platform.csv: %d members & %d lines with data; VERSION = %5.3f\n',... + self.members, self.size, VERSION) ; fprintf( fid, '%% $Id$\n%%\n'); @@ -52,8 +56,14 @@ for i=1:self.size; switch type{j} case 'char' format = '%s'; + case 'byte' + format = '%u'; case 'integer' format = '%d'; + case 'float' + format = '%f'; + case 'double' + format = '%lf'; otherwise format = '%s'; end diff --git a/TODOS b/TODOS index cb22b084d293142c00c95fb4672397e0437ff6f1..655f4d59af264f90a7810e77b3b18f80d72071ef 100644 --- a/TODOS +++ b/TODOS @@ -1,7 +1,7 @@ $Id$ -14/01/2007: +14/01/2008: ----------- Trace du trajet du navire : - Tester le trace avec un navire traversant la @@ -143,3 +143,12 @@ J'ai aussi vu 2 problemes qui rendent le QC difficile: - Aussi, pour le Havannah, les Loyautes n'apparaissent pas avec les lignes de cotes utilisees (et ca doit etre vrai pour d'autres iles du Pacifique ou les navires font escale), il faudrait un trait de cote plus precis (image jointe) + +23/01/2009 : corrige le 26/01/2009 +---------------------------------- +Les 6 variables SSPS_DEPH, SSPS_DEPH_MIN, SSPS_DEPH_MAX SSTP_DEPH, etc +peuvent etre saisie dans le masque (headerForm) mais ne sont pas sauvegardes +ni dans le fichier netcdf, ni dans @tsg_nc\platform.csv + +Reste un pb a corriger: l'entete du fichier @tsg_nc\platform.csv qui devrait +etre realise par existPlatform.m est egalement code en dur dans @tsg_nc/save diff --git a/tsg_io/existPlatform.m b/tsg_io/existPlatform.m index a66ff6b865558fabaa446e16f5a484d9232a5a4b..f57a0eaa118cae7ebaf9dbeb9e3627b38ee98b63 100644 --- a/tsg_io/existPlatform.m +++ b/tsg_io/existPlatform.m @@ -1,24 +1,61 @@ function existPlatform( hMainFig ) +global VERSION + % Get the data from the application GUI % ------------------------------------- tsg = getappdata(hMainFig, 'tsg_data'); +% get filename +% ------------ filename = [tsg.DEFAULT_PATH_FILE '@tsg_nc' filesep 'tsg_platform.csv']; -if ~exist( 'tsg_platform.csv' ) - +% check if filename exist and should be open in read mode +% ------------------------------------------------------- +fid = fopen(filename); +if (fid ~= -1) + + % ------------- + inputText = textscan(fid, '%s', 1, 'delimiter', '\n'); + + % use string instead cell + % ----------------------- + str = inputText{1}{1}; + + % if reach end of header + % ---------------------- + match = regexp( str, 'VERSION\s*=\s*(.*)', 'tokens'); + + % exit while loop if end of header + % -------------------------------- + if isempty(match) + fclose(fid); + create_platform_file; + end +else + create_platform_file; +end + + + % create new file tsg_platform.csv. Variables SSPS_DEPH ... have changed + % from integer to float since V1.0RC5 (VERSION = 0.905) + % ---------------------------------------------------------------------- + function create_platform_file() + fid = fopen( filename, 'wt' ); - fprintf( fid, '%% tsg_platform.csv: 14 members & 0 lines with data \n'); + fprintf( fid, '%% tsg_platform.csv: 14 members & 0 lines with data; VERSION = %5.3f\n', ... + VERSION); fprintf( fid, '%% $Id$ \n'); fprintf( fid, '%% \n' ); fprintf( fid, 'id;PLATFORM_NAME;SHIP_CALL_SIGN;SHIP_MMSI;TSG_TYPE;TSG_NUMBER;TINT_TYPE;TINT_NUMBER;SAMPLING_PERIOD;SSPS_DEPH;SSPS_DEPH_MIN;SSPS_DEPH_MAX;SSTP_DEPH;SSTP_DEPH_MIN;SSTP_DEPH_MAX;DATE_TSG;endl \n'); - fprintf( fid, 'char;char;char;char;char;char;char;char;integer;integer;integer;integer;integer;integer;integer;integer;integer \n'); + fprintf( fid, 'char;char;char;char;char;char;char;char;integer;integer;float;float;float;float;float;float;float \n'); fclose( fid ); - + % Refresh function and file system caches % --------------------------------------- rehash; + end + end \ No newline at end of file diff --git a/tsg_util/headerForm.m b/tsg_util/headerForm.m index 283d200b401a00f18af6dc0bf85d92799c9e1806..d5ada4ab00b0901a9943f7c9df27248317097479 100644 --- a/tsg_util/headerForm.m +++ b/tsg_util/headerForm.m @@ -41,6 +41,11 @@ date = datestr(now,30); nca = tsg_nc('tsg_ncattr.csv'); nca_keys = keys(nca); +% set additionals variables, location may be change in the future +% --------------------------------------------------------------- +add_var = { 'SSPS_DEPH', 'SSPS_DEPH_MIN', 'SSPS_DEPH_MAX', ... + 'SSTP_DEPH', 'SSTP_DEPH_MIN', 'SSTP_DEPH_MAX'}; + % Load platform_info object from tsg_platform_info.csv % ---------------------------------------------------- existPlatform(hTsgGUI); @@ -64,13 +69,13 @@ hHeaderFig = figure(... % bg = [0.92549 0.913725 0.847059] = get(0, 'DefaultUIControlBackgroundColor'); -% Iterate from each element from object nca -% ------------------------------------- -for i=1:numel(nca_keys) +% Iterate from each element from object nca and additional variables +% ------------------------------------------------------------------ +for i = nca_keys - % get key, use {} for cell - % ------------------------ - key = nca_keys{i}; + % get key, use char because i is cell + % ----------------------------------- + key = char(i); % get all structure for the key % ----------------------------- @@ -130,16 +135,26 @@ for i=1:numel(nca_keys) % set dynamically uicontrol from tsg struct % ----------------------------------------- switch s.uicontrolType + + % for a popmenu control, set index position + % --------------------------------- case 'popupmenu' str = cellstr(get(ui,'String')); ind = strfind(str,tsg.(key)); - for k=1:numel(ind) + for k=1:numel(ind) if ~isempty(ind{k}) set(ui, 'value', k); end - end + end + + % for edit control, set uicontrol with tsg.(key) value + % ---------------------------------------------------- case 'edit' + set(ui, 'string', tsg.(key)); + + % for checkbox control, not yet implemented + % ------------------------------------------ case 'checkbox' % not yet implemented !!! end @@ -212,26 +227,26 @@ uiwait(hHeaderFig); % get the PLATFORM_NAME value, use tag to retrieve % ------------------------------------------------ - value = get(findobj('Tag', 'PLATFORM_NAME'), 'string'); + platform_name = get(findobj('Tag', 'PLATFORM_NAME'), 'string'); % get platform info structure from hashtable store in platform_info object % ------------------------------------------------------------------------ - p_i = get(platform_info, value); + p_i = get(platform_info, platform_name); % get hashtable describing platform_info structure data type % ---------------------------------------------------------- hdr = header(platform_info); - % Iterate from each element from object nca - % ------------------------------------- - for ii=1:numel(nca_keys) + % Iterate from each element from object nca + additional variables + % ---------------------------------------------------------------- + for ncak = nca_keys - % get key, use {} for cell - % ------------------------ - key = nca_keys{ii}; + % get key, use char for cell ncak + % ---------------------------- + key = char(ncak); - % get all structure for the key - % ----------------------------- + % get all structure for the key, for additional variables, s = {} + % -------------------------------------------------------------- s = get(nca, key); % get the corresponding string from uicontrol using guihandles @@ -241,7 +256,7 @@ uiwait(hHeaderFig); % if uicontrol is a popupmenu, string is cell array with all choices % ------------------------------------------------------------------ - if strcmp(s.uicontrolType,'popupmenu') + if ~isempty(s) && strcmp(s.uicontrolType,'popupmenu') % get the corresponding string from cell array using selected value % ------------------------------------------------------------------ @@ -280,6 +295,14 @@ uiwait(hHeaderFig); end end end + + % get additional variables from uicontrol and update tsg struct + % ------------------------------------------------------------- + for kk = add_var + key = char(kk); + tsg.(key) = single(str2double(get(data.(key), 'string'))); + p_i.(key) = tsg.(key); + end % Save tsg structure % ------------------ @@ -287,7 +310,7 @@ uiwait(hHeaderFig); % test if uicontrol not empty % --------------------------- - if isempty(value) + if isempty(platform_name) warndlg({'PLATFORM NAME is empty';'';'Please, enter a valid PLATFORM name'},... 'Invalid PLATFORM name'); else @@ -295,7 +318,7 @@ uiwait(hHeaderFig); % Update plateform_info object with this PLATFORM_NAME value and % platform info updated structure % -------------------------------------------------------------- - platform_info = set(platform_info, value, p_i); + platform_info = set(platform_info, platform_name, p_i); % save object in csv file % ----------------------- @@ -316,7 +339,7 @@ uiwait(hHeaderFig); end - end + end % end of continueCallback nested function % ----------------------------------------------------------------------- % Cancel button, no action @@ -335,7 +358,7 @@ uiwait(hHeaderFig); % ----------------------------- error = -1; - end + end % end of cancelCallback nested function % ----------------------------------------------------------------------- % Callback when uicontrol PLATFORM_NAME is modified @@ -344,31 +367,28 @@ uiwait(hHeaderFig); % get the new value, use tag to retrieve % -------------------------------------- - value = get(findobj('Tag', 'PLATFORM_NAME'), 'string'); + platform_name = get(findobj('Tag', 'PLATFORM_NAME'), 'string'); % get platform info structure from hashtable store in platform_info object % ------------------------------------------------------------------------ - p_i = get(platform_info, value); + p_i = get(platform_info, platform_name); % get hashtable describing platform_info structure data type % ---------------------------------------------------------- - hdr = header(platform_info); + %hdr = header(platform_info); % if this platform exist, structure not empty % ------------------------------------------- if ~isempty(p_i) - % get members list of structure platform_name - % ------------------------------------------- - nb = fieldnames(p_i); - - % iterate on all members - % ---------------------- - for ii=1:numel(nb) + % iterate on all members of platform_info structure, filenames return + % a cell array of string + % ------------------------------------------------------------------- + for ii = fieldnames(p_i) - % key member name and use it as a key for tsg structure - % ----------------------------------------------------- - key = nb{ii}; + % convert each cell to char + % ------------------------- + key = char(ii); % update tsg with data from platform_info struct % TODOS: @@ -402,7 +422,7 @@ uiwait(hHeaderFig); % ----------------------------------------------------------------- else selection = ... - questdlg(['PLATFORM NAME: ' value ' is new. Do you want to use and save it ?'],... + questdlg(['PLATFORM NAME: ' platform_name ' is new. Do you want to use and save it ?'],... 'Create new PLATFORM NAME ?',... 'Yes', 'No', 'No'); @@ -418,17 +438,26 @@ uiwait(hHeaderFig); end end - end + end % end of updateForm nested function % additionnal variable here % ------------------------- function add_variables(bottom, left, s) + + % get the PLATFORM_NAME value, use tag to retrieve + % ------------------------------------------------ + platform_name = get(findobj('Tag', 'PLATFORM_NAME'), 'string'); - nPara = 6; - para = { 'SSPS_DEPH'; 'SSPS_DEPH_MIN'; 'SSPS_DEPH_MAX'; ... - 'SSTP_DEPH'; 'SSTP_DEPH_MIN'; 'SSTP_DEPH_MAX'}; + % get platform info structure from hashtable store in platform_info object + % ------------------------------------------------------------------------ + p_i = get(platform_info, platform_name); - for ipara= 1 : nPara + % display dynamically uicontrol text over add_var list + % ---------------------------------------------------- + for ad = add_var + + key = char(ad); + uicontrol(... 'Parent', hHeaderFig, ... 'Units', 'normalized', ... @@ -437,7 +466,7 @@ uiwait(hHeaderFig); 'HorizontalAlignment', 'left', ... 'Position',[left, bottom, s.length, s.height], ... 'TooltipString', '', ... - 'String', char(para{ipara})); + 'String', key); ui = uicontrol(... 'Parent', hHeaderFig, ... @@ -448,7 +477,7 @@ uiwait(hHeaderFig); 'HorizontalAlignment', 'right', ... 'Position', [left + s.length, bottom, s.length, s.height], ... 'String', '', ... - 'Tag', char(para{ipara})); + 'Tag', key); % Check vertical position of last uicontrol and creation new colomn % ----------------------------------------------------------------- @@ -457,7 +486,22 @@ uiwait(hHeaderFig); bottom = 0.95; left = left + inc_x; end + + + % update uicontrol from tsg structure or plateform_info + % ----------------------------------------------------- + if isempty( tsg.(key) ) + + % get value from platform_info + % ---------------------------- + if ~isempty(p_i) + set(ui, 'string', p_i.(key)); + end + else + set(ui, 'string', tsg.(key)); + end end - end -end + end % end of add_variables nested function + +end % end of headerForm diff --git a/tsgqc.m b/tsgqc.m index 2c4a388ee052e70506ff8725cc9a73470c5e8365..cb11f3ee0687376c2941c97a600d6d0a344a5481 100644 --- a/tsgqc.m +++ b/tsgqc.m @@ -40,7 +40,10 @@ clc; % ------------------------------------- global VERSION -VERSION = '0.2f'; +% version number, may be used to initialize some files when it change +% 0.90x -> 1.0RCx +% ------------------------------------------------------------------- +VERSION = 0.905; % Find program directory. % functions (icons) should be store at a lower level