Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Achim Morschhauser
GeomagLogger
Commits
4443b581
Commit
4443b581
authored
Feb 19, 2021
by
Achim Morschhauser
Browse files
Add pop() to buffer_obs_file_binary
parent
8ff9040b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/buffer_obs_file_binary.cpp
View file @
4443b581
...
...
@@ -20,6 +20,7 @@
// C headers
#include
<time.h>
#include
<typeinfo>
#include
<stdint.h>
// Custom C++ Headers
#include
<buffer_obs_file_binary.hpp>
// Buffer using File I/O
...
...
@@ -92,13 +93,58 @@ int buffer_obs_file_binary::put(data_obs* data) {
/********************************************************************************
* *
* Read data from the buffer. This is done by reading from Standard Input and *
* parsing the string. *
* Read data from the buffer. *
* *
********************************************************************************/
int
buffer_obs_file_binary
::
pop
(
data_obs
*
data
)
{
return
(
-
1
);
struct
timespec
time
;
std
::
vector
<
double
>
values_orig
;
std
::
vector
<
float
>
values
;
int
N
;
int32_t
tmp_32
;
// Write data info to stderr
if
(
!
info_written
){
info
(
data
);
}
// Open new file if necessary
check
(
data
);
if
(
!
file
.
is_open
()
)
{
std
::
cerr
<<
"No file opened for reading."
<<
std
::
endl
;
return
(
-
1
);
}
// Read time
read
((
char
*
)
&
tmp_32
,
sizeof
(
tmp_32
));
if
(
!
file
.
eof
())
{
time
.
tv_sec
=
(
time_t
)
tmp_32
;
read
((
char
*
)
&
tmp_32
,
sizeof
(
tmp_32
));
time
.
tv_nsec
=
(
long
)
tmp_32
;
data
->
set_time
(
&
time
);
// Read data
//TODO Add option for reading supplementary data
N
=
data
->
get_Ndata
();
values
.
resize
(
N
,
data
->
get_MD
());
read
((
char
*
)
values
.
data
(),
sizeof
(
values
[
0
])
*
N
);
values_orig
.
assign
(
values
.
begin
(),
values
.
end
());
if
((
data
->
set_data
(
values_orig
))
<
0
)
{
std
::
cerr
<<
"COULD NOT ASSIGN DATA"
<<
std
::
endl
;
}
return
(
0
);
}
else
{
std
::
cerr
<<
"END OF FILE REACHED"
<<
std
::
endl
;
data
->
set_values_MD
();
return
(
-
1
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment