Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dune-raw-data
dune-raw-data
Overlays
PennMicroSliceWriter.cc
Go to the documentation of this file.
1
#include "
dune-raw-data/Overlays/PennMicroSliceWriter.hh
"
2
3
dune::PennMicroSliceWriter::
4
PennMicroSliceWriter
(uint8_t*
address
, uint32_t max_size_bytes) :
5
//uint8_t sequence_id) :
6
PennMicroSlice
(address), max_size_bytes_(max_size_bytes)
7
{
8
header_
()->
format_version
= 0xE1;
9
//header_()->sequence_id = sequence_id;
10
header_
()->
block_size
=
sizeof
(
Header
);
11
12
if
(
max_size_bytes_
<
size
()) {
13
max_size_bytes_
=
size
();
14
}
15
}
16
17
/*
18
void dune::PennMicroSliceWriter::setSequenceId(uint8_t sequence_id)
19
{
20
header_()->sequence_id = sequence_id;
21
}
22
*/
23
24
/*
25
bool dune::PennMicroSliceWriter::addSample(uint16_t value)
26
{
27
if ((size() + sizeof(value)) > max_size_bytes_) {
28
return false;
29
}
30
data_()[header_()->sample_count] = value;
31
++(header_()->sample_count);
32
header_()->nanoslice_size += sizeof(value);
33
return true;
34
}
35
*/
36
37
bool
dune::PennMicroSliceWriter::addData
(uint16_t*
data
, uint16_t data_size)
38
{
39
if
((
size
() + data_size) >
max_size_bytes_
) {
40
return
false
;
41
}
42
for
(uint16_t i = 0; i < data_size; i++) {
43
uint16_t
value
= data[i];
44
data_
()[i] =
value
;
45
header_
()->
block_size
+=
sizeof
(
value
);
46
}
47
return
true
;
48
}
49
50
int32_t
dune::PennMicroSliceWriter::finalize
()
51
{
52
int32_t size_diff =
max_size_bytes_
-
header_
()->
block_size
;
53
max_size_bytes_
=
header_
()->
block_size
;
54
return
size_diff;
55
}
56
57
dune::PennMicroSlice::Header
*
dune::PennMicroSliceWriter::header_
()
58
{
59
return
reinterpret_cast<
Header
*
>
(
buffer_
);
60
}
61
62
uint16_t *
dune::PennMicroSliceWriter::data_
()
63
{
64
// This is not really a good solution.
65
return
reinterpret_cast<
uint16_t *
>
(
buffer_
+
sizeof
(
Header
));
66
}
dune::PennMicroSliceWriter::addData
bool addData(uint16_t *data, uint16_t data_size)
Definition:
PennMicroSliceWriter.cc:37
dune::PennMicroSliceWriter::header_
Header * header_()
Definition:
PennMicroSliceWriter.cc:57
address
Definition:
tableAs_t.cc:76
dune::PennMicroSliceWriter::finalize
int32_t finalize()
Definition:
PennMicroSliceWriter.cc:50
dune::PennMicroSlice::buffer_
uint8_t * buffer_
Definition:
PennMicroSlice.hh:735
dune::PennMicroSliceWriter::data_
uint16_t * data_()
Definition:
PennMicroSliceWriter.cc:62
dune::PennMicroSliceWriter::PennMicroSliceWriter
PennMicroSliceWriter(uint8_t *address, uint32_t max_size_bytes)
Definition:
PennMicroSliceWriter.cc:4
dune::PennMicroSlice::size
dune::PennMicroSlice::microslice_size_t size() const
Definition:
PennMicroSlice.cc:23
make_THn_beam_input.data
data
Definition:
make_THn_beam_input.py:80
dune::PennMicroSlice::Header::format_version
format_version_t format_version
Definition:
PennMicroSlice.hh:103
dune::PennMicroSlice
Definition:
PennMicroSlice.hh:13
PennMicroSliceWriter.hh
dune::PennMicroSlice::Header
Header of ethernet packet.
Definition:
PennMicroSlice.hh:92
dune::PennMicroSlice::Header::block_size
block_size_t block_size
Definition:
PennMicroSlice.hh:101
submit_mcc.value
value
Definition:
submit_mcc.py:159
dune::PennMicroSliceWriter::max_size_bytes_
uint32_t max_size_bytes_
Definition:
PennMicroSliceWriter.hh:44
Generated by
1.8.11