Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TSG QC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
US191
TSG QC
Commits
6c4bd968
Commit
6c4bd968
authored
12 years ago
by
jacques.grelet_ird.fr
Browse files
Options
Downloads
Patches
Plain Diff
add new .ini file format 1.30 and correct use of TSG installation date and S/N, same with TINT
parent
099cc669
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tsg_io/readTsgIniLabview.m
+126
-20
126 additions, 20 deletions
tsg_io/readTsgIniLabview.m
with
126 additions
and
20 deletions
tsg_io/readTsgIniLabview.m
+
126
−
20
View file @
6c4bd968
...
...
@@ -49,13 +49,14 @@ while ~feof(fid)
context
=
match
{
1
}{
1
};
end
% build tsg struct from global attributes
% check if we are is the right paragraph context
% ----------------------------------------------
if
strcmp
(
context
,
'GLOBAL'
)
||
strcmp
(
context
,
'GENERAL'
)
||
...
strcmp
(
context
,
tsg
.
TYPE_TSG
)
||
strcmp
(
context
,
tsg
.
TYPE_TINT
)
strcmp
(
context
,
tsg
.
TYPE_TSG
)
||
strcmp
(
context
,
tsg
.
TYPE_TINT
)
% Iterate from each element from
object nca and additional variables
% --------------------------------------------------------------
----
% Iterate from each element from
global attributes (nca object)
% --------------------------------------------------------------
for
ii
=
nca_keys
% get key, use char because i is cell
...
...
@@ -70,14 +71,15 @@ while ~feof(fid)
regex
=
strcat
(
'^\s*'
,
clef
,
'\s*=\s*["]*(.+?)["]*$'
);
match
=
regexp
(
str
,
regex
,
'tokens'
);
% build tsg struct
% ----------------
if
~
isempty
(
match
)
%if isnan(str2double(match{1}{1}))
tsg
.
(
clef
)
=
match
{
1
}{
1
};
%else
% tsg.(clef) = sprintf('%f',str2double(match{1}{1}));
%end
% for debbuging only
% ------------------
fprintf
(
'%s -> %s\n'
,
clef
,
tsg
.
(
clef
));
continue
end
...
...
@@ -85,9 +87,105 @@ while ~feof(fid)
end
% get TSG installation date and S/N
% ---------------------------------
if
strcmp
(
context
,
tsg
.
TYPE_TSG
)
||
strcmp
(
context
,
tsg
.
TYPE_TINT
)
||
...
strcmp
(
context
,
'SENSORS'
)
% Iterate from each element from object nca attributes
% ----------------------------------------------------
for
ii
=
nca_keys
% get key, use char because i is cell
% -----------------------------------
clef
=
char
(
ii
);
% construct regex with pair cle=value
% and extract value
% use quantifier none greedy (.*?)
% remove double quote from expression : ["]*
% ---------------------------------------------------
if
~
isempty
(
strfind
(
clef
,
'DATE_'
))
regex
=
strcat
(
'^\s*('
,
tsg
.
TYPE_TSG
,
'.|'
,
tsg
.
TYPE_TINT
,
...
'.)?('
,
clef
,
')?\s*=\s*["]*(.*?)["]*$'
);
match
=
regexp
(
str
,
regex
,
'tokens'
);
elseif
~
isempty
(
strfind
(
clef
,
'NUMBER_'
))
regex
=
strcat
(
'^\s*('
,
tsg
.
TYPE_TSG
,
'.|'
,
tsg
.
TYPE_TINT
,
...
'.)?'
,
clef
,
'\s*=\s*["]*(.*?)["]*$'
);
match
=
regexp
(
str
,
regex
,
'tokens'
);
else
match
=
[];
end
% build tsg struct
% ----------------
if
~
isempty
(
match
)
switch
size
(
match
{
1
},
2
)
% in case of calibration coefficients, have key/value pair
% --------------------------------------------------------
case
3
% get key
% --------
k
=
match
{
1
}{
2
};
% get value
% ---------
v
=
match
{
1
}{
3
};
% convert date in yyyymmddHHMMSS convention
% in next version use ISO8660 format yyyyddmmTHHMMSSZ
% -------------------------------------------------------------
if
~
isempty
(
strfind
(
k
,
'DATE_'
))
v
=
datestr
(
datenum
(
v
,
'dd/mm/yyyy'
),
'yyyymmddHHMMSS'
);
else
% in case where comma is decimal separator, replace it
% with by dot
% ----------------------------------------------------
v
=
str2double
(
regexprep
(
v
,
','
,
'.'
));
end
% add value to coefficients array
% -------------------------------
tsg
.
(
clef
)
=
v
;
% for debbuging only
% ------------------
fprintf
(
'%s => %s\n'
,
clef
,
tsg
.
(
clef
));
case
2
% add value to variable array
% in case where comma is decimal separator, replace it
% with by dot
% ----------------------------------------------------
tsg
.
(
clef
)
=
str2double
(
regexprep
(
match
{
1
}{
2
},
','
,
'.'
));
% for debbuging only
% ------------------
fprintf
(
'%s => %f\n'
,
clef
,
tsg
.
(
clef
));
end
% quit for loop
% -------------
continue
end
end
% end of match
end
% check if we are is the right paragraph context
% ----------------------------------------------
if
strcmp
(
context
,
tsg
.
TYPE_TSG
)
||
strcmp
(
context
,
tsg
.
TYPE_TINT
)
% since SODA V1.30, all sensors information are in SENSORS group
% --------------------------------------------------------------
if
strcmp
(
context
,
tsg
.
TYPE_TSG
)
||
strcmp
(
context
,
tsg
.
TYPE_TINT
)
||
...
strcmp
(
context
,
'SENSORS'
)
% Iterate from each element from object nca and additional variables
% ------------------------------------------------------------------
...
...
@@ -101,13 +199,21 @@ while ~feof(fid)
% simple variables are : SSPS_DEPH=8.00000000E+0
% coeff variables are : SSJT_CALCOEF_G=4,23058298E-3 or
% CNDC_LINCOEF_OFFSET=0.00000000E+0
% SODA 1.30
% [SENSORS]
% SBE21.DATE_TSG = "14/06/2010"
% SBE21.NUMBER_TSG = "2653"
% SBE38.DATE_TINT = "01/10/2007"
% SBE38.NUMBER_TINT = "2552"
% SBE38.SSTP_CALCOEF_G = "4.1100000000E-3"
% ------------------------------------
if
~
isempty
(
strfind
(
clef
,
'COEF'
))
regex
=
strcat
(
'^\s*'
,
clef
,
'_(\w+)?\s*=\s*["]*(.*?)["]*$'
);
regex
=
strcat
(
'^\s*('
,
tsg
.
TYPE_TSG
,
'.|'
,
tsg
.
TYPE_TINT
,
...
'.)?'
,
clef
,
'_(\w+)?\s*=\s*["]*(.*?)["]*$'
);
match
=
regexp
(
str
,
regex
,
'tokens'
);
elseif
~
isempty
(
strfind
(
clef
,
'DEPH'
))
regex
=
strcat
(
'^\s*'
,
clef
,
'\s*=\s*["]*(.*?)["]*$'
);
%regex = strcat('^\s*\w*_DEPH_?\w*\s*=\s*(\w.+)
$');
regex
=
strcat
(
'^\s*
(
'
,
tsg
.
TYPE_TSG
,
'.|'
,
tsg
.
TYPE_TINT
,
...
'.)?'
,
clef
,
'\s*=\s*["]*(.*?)["]*
$'
);
match
=
regexp
(
str
,
regex
,
'tokens'
);
else
match
=
[];
...
...
@@ -123,20 +229,20 @@ while ~feof(fid)
% in case of calibration coefficients, have key/value pair
% --------------------------------------------------------
case
2
case
3
% get key
% --------
k
=
match
{
1
}{
1
};
k
=
match
{
1
}{
2
};
% get value
% ---------
v
=
match
{
1
}{
2
};
v
=
match
{
1
}{
3
};
% convert date in julian day when key is 'DATE', else to double
% -------------------------------------------------------------
if
strcmpi
(
k
,
'DATE'
)
v
=
datenumToJulian
(
datenum
(
v
,
'dd/mm/yyyy'
));
if
strcmpi
(
k
,
'DATE'
)
v
=
datenumToJulian
(
datenum
(
v
,
'dd/mm/yyyy'
));
else
% in case where comma is decimal separator, replace it
...
...
@@ -157,17 +263,17 @@ while ~feof(fid)
% ------------------
fprintf
(
'%s: %s -> %f\n'
,
clef
,
k
,
v
);
case
1
case
2
% add value to variable array
% in case where comma is decimal separator, replace it
% with by dot
% ----------------------------------------------------
tsg
.
(
clef
)
=
str2double
(
regexprep
(
match
{
1
}{
1
},
','
,
'.'
));
tsg
.
(
clef
)
=
str2double
(
regexprep
(
match
{
1
}{
2
},
','
,
'.'
));
% for debbuging only
% ------------------
%
fprintf('%s: %f\n', clef, tsg.(clef));
fprintf
(
'%s: %f\n'
,
clef
,
tsg
.
(
clef
));
end
% quit for loop
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment