Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
CTA-LAPP
PHOENIX_LIBS
PhoenixHDF5
Commits
33370725
Commit
33370725
authored
Nov 25, 2020
by
Pierre Aubert
Browse files
Add test with several table
parent
f8490f77
Pipeline
#92664
passed with stages
in 2 minutes and 48 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
129 additions
and
4 deletions
+129
-4
TESTS/CMakeLists.txt
TESTS/CMakeLists.txt
+1
-0
TESTS/TEST_TABLE_CONFIG/CMakeLists.txt
TESTS/TEST_TABLE_CONFIG/CMakeLists.txt
+14
-0
TESTS/TEST_TABLE_CONFIG/configTable.ph5
TESTS/TEST_TABLE_CONFIG/configTable.ph5
+16
-0
TESTS/TEST_TABLE_CONFIG/main.cpp
TESTS/TEST_TABLE_CONFIG/main.cpp
+91
-0
TESTS/TEST_TYPE/configType.ph5
TESTS/TEST_TYPE/configType.ph5
+1
-1
src/BackEnd/backend.cpp
src/BackEnd/backend.cpp
+6
-3
No files found.
TESTS/CMakeLists.txt
View file @
33370725
...
...
@@ -12,4 +12,5 @@ include(callGenerator.cmake)
add_subdirectory
(
TEST_BASE_CONFIG
)
add_subdirectory
(
TEST_TYPE
)
add_subdirectory
(
TEST_TYPE_T
)
add_subdirectory
(
TEST_TABLE_CONFIG
)
TESTS/TEST_TABLE_CONFIG/CMakeLists.txt
0 → 100644
View file @
33370725
project
(
Phoenix
)
cmake_minimum_required
(
VERSION 2.8
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
)
call_generator
(
test_table_config_lib configTable.ph5
)
add_executable
(
test_table_config main.cpp
)
target_link_libraries
(
test_table_config test_table_config_lib
${
HDF5_CXX_LIBRARIES
}
)
add_test
(
NAME TestTableConfig
COMMAND
${
CMAKE_CURRENT_BINARY_DIR
}
/test_table_config
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
)
TESTS/TEST_TABLE_CONFIG/configTable.ph5
0 → 100644
View file @
33370725
///Table of types
TableEvent{
///Event id
size_t eventId;
///Timestamp
double timestamp;
///Waveform
Tensor(unsigned short, nbSlice, nbPixel) waveform;
///Short value
Tensor(float, nbPixel) calibSignal;
}
TESTS/TEST_TABLE_CONFIG/main.cpp
0 → 100644
View file @
33370725
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#include "configTable.h"
///Test to write data
/** @param fileName : name of the file to be written
* @return true on success, false otherwise
*/
bool
testWriteData
(
const
std
::
string
&
fileName
){
TableEvent
table
;
size_t
nbRow
(
10lu
),
nbSlice
(
40lu
),
nbPixel
(
1855lu
);
table
.
setAllDim
(
nbPixel
,
nbSlice
);
table
.
resize
(
nbRow
);
//Let's set some values in the Table
for
(
size_t
i
(
0lu
);
i
<
nbRow
;
++
i
){
table
.
setEventId
(
i
,
i
);
table
.
setTimestamp
(
i
,
2lu
*
i
);
unsigned
short
*
waveform
=
table
.
getWaveform
(
i
);
for
(
size_t
j
(
0lu
);
j
<
nbSlice
;
++
j
){
for
(
size_t
k
(
0lu
);
k
<
nbPixel
;
++
k
){
waveform
[
j
*
nbPixel
+
k
]
=
29lu
*
(
i
*
nbRow
+
j
*
nbPixel
+
k
)
%
19lu
;
}
}
float
*
tabSignal
=
table
.
getCalibSignal
(
i
);
for
(
size_t
k
(
0lu
);
k
<
nbPixel
;
++
k
){
tabSignal
[
k
]
=
43lu
*
(
i
*
nbRow
+
k
)
%
17lu
;
}
}
//Now let's open a file
H5
::
H5File
file
(
fileName
,
H5F_ACC_TRUNC
);
//And write our table directly in it
table
.
write
(
file
);
//We can also explicitly cloase the file, otherwise it will do it automatically
file
.
close
();
return
true
;
}
///Test to read data
/** @param fileName : name of the file to be read
* @return true on success, false otherwise
*/
bool
testReadData
(
const
std
::
string
&
fileName
){
//First let's open a file in read only mode (better for concurencial access)
H5
::
H5File
file
(
fileName
,
H5F_ACC_RDONLY
);
//Let's create our table
TableEvent
table
;
//Add read the file
table
.
read
(
file
);
//Now we can close the file and use the Table directly
file
.
close
();
//Get the number of rows and number of columns
size_t
nbRow
=
table
.
getNbRow
(),
nbPixel
=
table
.
getNbPixel
(),
nbSlice
=
table
.
getNbSlice
();
bool
b
(
true
);
for
(
size_t
i
(
0lu
);
i
<
nbRow
;
++
i
){
b
&=
table
.
getEventId
(
i
)
==
i
;
b
&=
table
.
getTimestamp
(
i
)
==
2lu
*
i
;
unsigned
short
*
waveform
=
table
.
getWaveform
(
i
);
for
(
size_t
j
(
0lu
);
j
<
nbSlice
;
++
j
){
for
(
size_t
k
(
0lu
);
k
<
nbPixel
;
++
k
){
b
&=
waveform
[
j
*
nbPixel
+
k
]
==
29lu
*
(
i
*
nbRow
+
j
*
nbPixel
+
k
)
%
19lu
;
}
}
float
*
tabSignal
=
table
.
getCalibSignal
(
i
);
for
(
size_t
k
(
0lu
);
k
<
nbPixel
;
++
k
){
b
&=
tabSignal
[
k
]
==
43lu
*
(
i
*
nbRow
+
k
)
%
17lu
;
}
}
return
b
;
}
int
main
(
int
argc
,
char
**
argv
){
std
::
string
fileName
(
"configTable.h5"
);
if
(
!
testWriteData
(
fileName
)){
std
::
cerr
<<
"Cannot write file '"
<<
fileName
<<
"'"
<<
std
::
endl
;
return
-
1
;
}
if
(
!
testReadData
(
fileName
)){
std
::
cerr
<<
"Cannot read file '"
<<
fileName
<<
"'"
<<
std
::
endl
;
return
-
1
;
}
return
0
;
}
TESTS/TEST_TYPE/configType.ph5
View file @
33370725
...
...
@@ -4,7 +4,7 @@ TableType{
///Float value
float valFloat;
///Double value
float
valDouble;
double
valDouble;
///In value
int valInt;
///Short value
...
...
src/BackEnd/backend.cpp
View file @
33370725
...
...
@@ -70,7 +70,7 @@ std::string ph5_backendTableHeaderOffset(const PTable & table){
std
::
string
body
(
""
);
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
body
+=
"
\t\t
static
size_t getOffset"
+
firstToUpper
(
it
->
getName
())
+
"();
\n
"
;
body
+=
"
\t\t
size_t getOffset"
+
firstToUpper
(
it
->
getName
())
+
"()
const
;
\n
"
;
}
return
body
;
}
...
...
@@ -453,11 +453,11 @@ std::string ph5_backendTableSourceOffset(const PTable & table){
body
+=
"///Get the offset of the attribute "
+
it
->
getName
()
+
"
\n
"
;
body
+=
"/**
\t
@return offset of the attribute in bytes
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"size_t "
+
name
+
"::getOffset"
+
firstToUpper
(
it
->
getName
())
+
"(){
\n
"
;
body
+=
"size_t "
+
name
+
"::getOffset"
+
firstToUpper
(
it
->
getName
())
+
"()
const
{
\n
"
;
if
(
prevAttribute
==
""
&&
prevAttributeSize
==
""
){
body
+=
"
\t
return 0lu;
\n
"
;
}
else
{
body
+=
"
\t
return
"
+
name
+
"::
getOffset"
+
firstToUpper
(
prevAttribute
)
+
"() + "
+
prevAttributeSize
+
";
\n
"
;
body
+=
"
\t
return getOffset"
+
firstToUpper
(
prevAttribute
)
+
"() + "
+
prevAttributeSize
+
";
\n
"
;
}
body
+=
"}
\n\n
"
;
prevAttribute
=
it
->
getName
();
...
...
@@ -514,6 +514,8 @@ std::string ph5_cTypeToHDF5(const std::string & type){
else
if
(
type
==
"unsigned short"
||
type
==
"uint16_t"
){
return
"H5::PredType::NATIVE_UINT16"
;}
else
if
(
type
==
"int"
||
type
==
"int32_t"
){
return
"H5::PredType::NATIVE_INT32"
;}
else
if
(
type
==
"unsigned int"
||
type
==
"uint32_t"
){
return
"H5::PredType::NATIVE_UINT32"
;}
else
if
(
type
==
"size_t"
||
type
==
"uint64_t"
){
return
"H5::PredType::NATIVE_UINT64"
;}
else
if
(
type
==
"ssize_t"
||
type
==
"int64_t"
){
return
"H5::PredType::NATIVE_INT64"
;}
else
if
(
type
==
"float"
){
return
"H5::PredType::NATIVE_FLOAT"
;}
else
if
(
type
==
"double"
){
return
"H5::PredType::NATIVE_DOUBLE"
;}
return
""
;
...
...
@@ -531,6 +533,7 @@ std::string ph5_getTypeHDF5(const PAttribute & attr){
size_t
i
(
0lu
);
for
(
PVecDim
::
const_iterator
it
(
vecDim
.
begin
());
it
!=
vecDim
.
end
();
++
it
){
body
+=
"
\t
dims["
+
convertToString
(
i
)
+
"] = "
+
ph5_dimentionToStr
(
*
it
,
"p_"
)
+
";
\n
"
;
++
i
;
}
body
+=
"
\t
H5::ArrayType arrayType("
+
ph5_cTypeToHDF5
(
attr
.
getType
())
+
", "
+
convertToString
(
vecDim
.
size
())
+
", dims);
\n
"
;
body
+=
"
\t
return arrayType;
\n
"
;
...
...
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