Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
XSF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
fleet
formats
XSF
Commits
db1853f9
Commit
db1853f9
authored
Jul 11, 2019
by
PONCELET
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update model to sonar netcdf 1.1
parent
ee5239bd
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1592 additions
and
1002 deletions
+1592
-1002
sources/xsf.generator/.classpath
sources/xsf.generator/.classpath
+1
-0
sources/xsf.generator/XSFModel.json
sources/xsf.generator/XSFModel.json
+1490
-988
sources/xsf.generator/src/main/java/fr/ifremer/fr/xsf/generator/AsciiDoctorGenerator.java
...ava/fr/ifremer/fr/xsf/generator/AsciiDoctorGenerator.java
+14
-5
sources/xsf.generator/src/main/java/fr/ifremer/fr/xsf/generator/CodeGenerator.java
.../main/java/fr/ifremer/fr/xsf/generator/CodeGenerator.java
+1
-1
sources/xsf.generator/src/main/java/fr/ifremer/fr/xsf/generator/DataTypeConverter.java
...n/java/fr/ifremer/fr/xsf/generator/DataTypeConverter.java
+43
-1
sources/xsf.generator/src/main/java/fr/ifremer/fr/xsf/generator/model/SCGroupAdapter.java
...ava/fr/ifremer/fr/xsf/generator/model/SCGroupAdapter.java
+7
-2
sources/xsf.generator/src/main/java/fr/ifremer/fr/xsf/generator/model/SCTypeAdapter.java
...java/fr/ifremer/fr/xsf/generator/model/SCTypeAdapter.java
+18
-0
sources/xsf.generator/src/main/java/fr/ifremer/fr/xsf/generator/model/SCVariableAdapter.java
.../fr/ifremer/fr/xsf/generator/model/SCVariableAdapter.java
+18
-5
No files found.
sources/xsf.generator/.classpath
View file @
db1853f9
...
...
@@ -10,6 +10,7 @@
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"test"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"
>
...
...
sources/xsf.generator/XSFModel.json
View file @
db1853f9
This diff is collapsed.
Click to expand it.
sources/xsf.generator/src/main/java/fr/ifremer/fr/xsf/generator/AsciiDoctorGenerator.java
View file @
db1853f9
...
...
@@ -188,15 +188,16 @@ public class AsciiDoctorGenerator {
creturn
(
context
.
currentOutput
);
}
private
void
writeVariables
(
List
<
Variable
>
variables
,
Context
context
)
throws
IOException
{
if
(
variables
.
isEmpty
())
return
;
reallyWriteVariable
(
"Variables"
,
variables
,
context
);
}
private
void
writeVariableAttributes
(
List
<
Attribute
>
attributes
,
Context
context
)
throws
IOException
{
for
(
Attribute
v:
attributes
)
{
if
(
v
.
getValue
().
compareTo
(
"Float.NaN"
)==
0
)
if
(
v
.
getValue
()
!=
null
&&
v
.
getValue
()
.
compareTo
(
"Float.NaN"
)==
0
)
continue
;
String
value
=
v
.
getType
()!=
null
?
v
.
getType
():
""
;
String
value
=
v
.
getType
()!=
null
?
v
.
getType
()
.
trim
()+
" "
:
""
;
value
+=
":"
;
value
+=
v
.
getName
();
//assume a string type
...
...
@@ -213,11 +214,19 @@ public class AsciiDoctorGenerator {
{
if
(
v
.
getValue
()!=
null
)
{
String
lValue
=
v
.
getValue
().
replaceAll
(
"\u002D"
,
"\u2212"
);
//on utilise des espace insécables pour se conformer à la doc WCFAST
value
+=
"\u00A0=\u00A0"
;
//remove hyphen minus U002D sign with minus sign U2212
value
+=
v
.
getValue
().
replaceAll
(
"\u002D"
,
"\u2212"
).
replaceAll
(
".0f"
,
".0"
);
if
(
v
.
getName
().
compareTo
(
"valid_range"
)==
0
)
{
value
+=
lValue
.
replaceAll
(
"f"
,
""
);
}
else
{
value
+=
lValue
.
replaceAll
(
".0f"
,
".0"
);
}
}
}
...
...
sources/xsf.generator/src/main/java/fr/ifremer/fr/xsf/generator/CodeGenerator.java
View file @
db1853f9
...
...
@@ -26,7 +26,7 @@ import fr.ifremer.fr.xsf.generator.model.Variable;
public
class
CodeGenerator
{
static
File
outputDir
=
new
File
(
"d:\\tmp"
);
static
File
outputDir
=
new
File
(
"d:\\tmp
\\XSFGenerator
"
);
private
static
final
String
OUTPUT_DIR_OPTION
=
"out"
;
private
static
final
String
MODEL_FILE_OPTION
=
"model"
;
...
...
sources/xsf.generator/src/main/java/fr/ifremer/fr/xsf/generator/DataTypeConverter.java
View file @
db1853f9
package
fr.ifremer.fr.xsf.generator
;
import
java.util.HashMap
;
import
java.util.List
;
public
class
DataTypeConverter
{
private
static
HashMap
<
String
,
DataType
>
vlen_specific_types
=
new
HashMap
<>();
public
static
DataType
get
(
String
value
)
throws
Exception
{
switch
(
value
.
toUpperCase
())
{
case
"BOOLEAN"
:
return
DataType
.
BOOLEAN
;
//on triche un peu et map les types enum sur des bytes
case
"TRANSDUCER_TYPE_T"
:
case
"DETECTION_TYPE_T"
:
case
"TRANSMIT_T"
:
case
"BYTE"
:
return
DataType
.
BYTE
;
case
"CHAR"
:
...
...
@@ -35,7 +41,43 @@ public class DataTypeConverter {
case
"STRING"
:
return
DataType
.
BYTE
;
default
:
throw
new
Exception
(
"Unknown netcdf type "
+
value
);
}
// type was not found, should be a specific type, as such it shall have been declared earlier
DataType
spec
=
vlen_specific_types
.
get
(
value
);
if
(
spec
!=
null
)
{
return
spec
;
}
throw
new
Exception
(
"Unknown netcdf type "
+
value
);
}
/**
* Check if a type is a user defined type
* */
public
static
boolean
isSpecific
(
String
name
)
{
return
vlen_specific_types
.
containsKey
(
name
);
}
/**
* declare a specific type
* @param name the name of the type
* @param declaration the declaration type (in a float* form)
* @return the name of the type
* */
public
static
String
declareType
(
String
declaration
)
{
//parse declaration
//ignore enum type for now
if
(
declaration
.
contains
(
"enum"
))
return
declaration
;
//we are in a float* case
String
[]
decode
=
declaration
.
split
(
" "
);
String
name
=
decode
[
1
];
String
typeName
=
decode
[
0
].
replace
(
"*"
,
""
).
replace
(
"("
,
""
).
replace
(
")"
,
""
);
DataType
type
=
DataType
.
getType
(
typeName
);
vlen_specific_types
.
put
(
name
,
type
);
return
name
;
}
}
sources/xsf.generator/src/main/java/fr/ifremer/fr/xsf/generator/model/SCGroupAdapter.java
View file @
db1853f9
...
...
@@ -9,6 +9,8 @@ import java.util.TreeSet;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.text.WordUtils
;
import
fr.ifremer.fr.xsf.generator.DataTypeConverter
;
public
class
SCGroupAdapter
{
private
static
boolean
forceVariableDeclaration
=
false
;
/** @return class name **/
...
...
@@ -62,7 +64,7 @@ public class SCGroupAdapter {
// Variable declaration
group
.
variables
.
forEach
(
v
->
sourceCode
.
add
(
SCVariableAdapter
.
getSourceDeclaration
(
v
)));
group
.
variables
.
forEach
(
v
->
sourceCode
.
add
All
(
SCVariableAdapter
.
getSourceDeclaration
(
v
)));
// Dimension declaration
group
.
dims
.
forEach
(
d
->
sourceCode
.
add
(
SCDimensionAdapter
.
getSourceDeclaration
(
d
)));
...
...
@@ -81,7 +83,10 @@ public class SCGroupAdapter {
// Types
if
(!
group
.
types
.
isEmpty
())
{
sourceCode
.
add
(
"\n\t\t/** Types **/"
);
group
.
types
.
forEach
(
t
->
sourceCode
.
add
(
"\t\t// "
+
t
.
name
));
group
.
types
.
forEach
(
t
->
{
String
name
=
DataTypeConverter
.
declareType
(
t
.
name
);
sourceCode
.
addAll
(
SCTypeAdapter
.
getSourceCode
(
name
));
});
}
// Dimensions
...
...
sources/xsf.generator/src/main/java/fr/ifremer/fr/xsf/generator/model/SCTypeAdapter.java
0 → 100644
View file @
db1853f9
package
fr.ifremer.fr.xsf.generator.model
;
import
java.util.Arrays
;
import
java.util.List
;
import
fr.ifremer.fr.xsf.generator.DataTypeConverter
;
public
class
SCTypeAdapter
{
public
static
List
<
String
>
getSourceCode
(
String
type
)
{
if
(
DataTypeConverter
.
isSpecific
(
type
))
{
return
Arrays
.
asList
(
String
.
format
(
"\t\tthis.addType(%s,%s);"
,
type
,
type
));
}
return
Arrays
.
asList
(
String
.
format
(
"\t\t// %s"
,
type
));
}
}
sources/xsf.generator/src/main/java/fr/ifremer/fr/xsf/generator/model/SCVariableAdapter.java
View file @
db1853f9
...
...
@@ -8,8 +8,10 @@ import fr.ifremer.fr.xsf.generator.DataTypeConverter;
public
class
SCVariableAdapter
{
public
static
String
getSourceDeclaration
(
Variable
variable
)
{
return
String
.
format
(
"\tprivate NCVariable %s;"
,
variable
.
name
);
public
static
List
<
String
>
getSourceDeclaration
(
Variable
variable
)
{
return
Arrays
.
asList
(
String
.
format
(
"\tpublic static final String %s=\"%s\";"
,
variable
.
name
.
toUpperCase
(),
variable
.
name
),
String
.
format
(
"\tprivate NCVariable %s;"
,
variable
.
name
));
}
public
static
List
<
String
>
getSourceAccessor
(
Variable
variable
)
{
...
...
@@ -50,9 +52,20 @@ public class SCVariableAdapter {
dimString
=
new
StringBuilder
(
"new ArrayList<NCDimension>()"
);
}
// variable declaration
codeLines
.
add
(
String
.
format
(
"\t\t%s = addVariable(\"%s\", DataType.%s, %s);"
,
variable
.
name
,
variable
.
name
,
DataTypeConverter
.
get
(
variable
.
type
.
toUpperCase
()).
name
(),
dimString
));
if
(
DataTypeConverter
.
isSpecific
(
variable
.
type
))
{
// variable declaration
codeLines
.
add
(
String
.
format
(
"\t\t%s = addVariable(%s, getTypes(%s).getReference(), %s);"
,
variable
.
name
,
variable
.
name
.
toUpperCase
(),
variable
.
type
,
dimString
));
}
else
{
// variable declaration
codeLines
.
add
(
String
.
format
(
"\t\t%s = addVariable(%s, DataType.%s, %s);"
,
variable
.
name
,
variable
.
name
.
toUpperCase
(),
DataTypeConverter
.
get
(
variable
.
type
).
name
(),
dimString
));
}
// attributes declarations
variable
.
attributes
.
forEach
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment