Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LEFEBVREJP email
radix
Commits
131b88fa
Commit
131b88fa
authored
Oct 08, 2018
by
Purves, Murray
Browse files
Amending PCF writer to correctly set string lengths
parent
8e362bbd
Pipeline
#16161
failed with stages
in 7 minutes and 24 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
radixio/spectrumpcfstream.i.hh
View file @
131b88fa
...
...
@@ -334,21 +334,22 @@ bool SpectrumPCFStream<data_type>::write_to(const std::string &file) const
{
radix_line
(
" File has DHS-type header"
);
stream
.
write
(
"DHS"
,
3
);
stream
.
write
(
mData
->
lastModifiedHash
().
c_str
(),
7
);
stream
.
write
(
mData
->
uuid
().
c_str
(),
36
);
stream
.
write
(
mData
->
inspection
().
c_str
(),
16
);
stream
.
write
(
make_length
(
mData
->
lastModifiedHash
()
,
7
)
.
c_str
(),
7
);
stream
.
write
(
make_length
(
mData
->
uuid
()
,
36
)
.
c_str
(),
36
);
stream
.
write
(
make_length
(
mData
->
inspection
()
,
16
)
.
c_str
(),
16
);
stream
.
writeShort
(
mData
->
laneNumber
());
stream
.
write
(
mData
->
measurementRemark
().
c_str
(),
26
);
stream
.
write
(
mData
->
instrumentType
().
c_str
(),
28
);
stream
.
write
(
mData
->
manufacturer
().
c_str
(),
28
);
stream
.
write
(
mData
->
instrumentModel
().
c_str
(),
18
);
stream
.
write
(
mData
->
instrumentID
().
c_str
(),
18
);
stream
.
write
(
mData
->
itemDescription
().
c_str
(),
20
);
stream
.
write
(
mData
->
measurementLocationName
().
c_str
(),
16
);
stream
.
write
(
mData
->
measurementLocationCoords
().
c_str
(),
16
);
stream
.
write
(
make_length
(
mData
->
measurementRemark
(),
26
).
c_str
(),
26
);
stream
.
write
(
make_length
(
mData
->
instrumentType
(),
28
).
c_str
(),
28
);
stream
.
write
(
make_length
(
mData
->
manufacturer
(),
28
).
c_str
(),
28
);
stream
.
write
(
make_length
(
mData
->
instrumentModel
(),
18
).
c_str
(),
18
);
stream
.
write
(
make_length
(
mData
->
instrumentID
(),
18
).
c_str
(),
18
);
stream
.
write
(
make_length
(
mData
->
itemDescription
(),
20
).
c_str
(),
20
);
stream
.
write
(
make_length
(
mData
->
measurementLocationName
(),
16
).
c_str
(),
16
);
stream
.
write
(
make_length
(
mData
->
measurementLocationCoords
(),
16
).
c_str
(),
16
);
stream
.
writeShort
(
mData
->
itemDetectorDistance
());
stream
.
writeShort
(
mData
->
occupancyNumber
());
stream
.
write
(
mData
->
cargoType
().
c_str
(),
16
);
stream
.
write
(
make_length
(
mData
->
cargoType
()
,
16
)
.
c_str
(),
16
);
// Add bytes written directly to eafstream count
stream
.
setBytesWritten
(
stream
.
bytesWritten
()
+
248
);
}
...
...
@@ -356,7 +357,7 @@ bool SpectrumPCFStream<data_type>::write_to(const std::string &file) const
{
radix_line
(
" File has non-DHS-type header"
);
stream
.
write
(
" "
,
3
);
stream
.
write
(
mData
->
energyCalibrationLabel
().
c_str
(),
4
);
stream
.
write
(
make_length
(
mData
->
energyCalibrationLabel
()
,
4
)
.
c_str
(),
4
);
stream
.
writeFloat
(
mData
->
energyCalibrationOffset
());
stream
.
writeFloat
(
mData
->
energyCalibrationGain
());
stream
.
writeFloat
(
mData
->
energyCalibrationQuadraticTerm
());
...
...
@@ -365,7 +366,8 @@ bool SpectrumPCFStream<data_type>::write_to(const std::string &file) const
// Add bytes written directly to eafstream count
stream
.
setBytesWritten
(
stream
.
bytesWritten
()
+
7
);
// Skip to 256 bytes (end of header)
stream
.
write
(
" "
,
256
-
stream
.
bytesWritten
());
stream
.
write
(
make_length
(
" "
,
256
-
stream
.
bytesWritten
()).
c_str
(),
256
-
stream
.
bytesWritten
());
// Add bytes written directly to eafstream count
stream
.
setBytesWritten
(
256
);
}
...
...
@@ -378,11 +380,12 @@ bool SpectrumPCFStream<data_type>::write_to(const std::string &file) const
{
radix_line
(
" Regular deviation pairs found:"
);
// Write regular deviation pairs
stream
.
write
(
mData
->
deviationPairPresence
().
c_str
(),
20
);
stream
.
write
(
make_length
(
mData
->
deviationPairPresence
()
,
20
)
.
c_str
(),
20
);
// Add bytes written directly to eafstream count
stream
.
setBytesWritten
(
stream
.
bytesWritten
()
+
20
);
// Skip to 512 bytes (start of pairs)
stream
.
write
(
" "
,
512
-
stream
.
bytesWritten
());
stream
.
write
(
make_length
(
" "
,
512
-
stream
.
bytesWritten
()).
c_str
(),
512
-
stream
.
bytesWritten
());
// Add bytes written directly to eafstream count
stream
.
setBytesWritten
(
512
);
...
...
@@ -407,17 +410,24 @@ bool SpectrumPCFStream<data_type>::write_to(const std::string &file) const
}
radix_line
(
"|"
);
}
// Skip to 256*83 bytes (start of spectral data)
stream
.
write
(
make_length
(
" "
,
(
256
*
83
)
-
stream
.
bytesWritten
()).
c_str
(),
(
256
*
83
)
-
stream
.
bytesWritten
());
// Add bytes written directly to eafstream count
stream
.
setBytesWritten
(
256
*
83
);
}
else
if
(
mData
->
deviationPairPresence
().
compare
(
"DeviationPairsInFileCompressed"
)
==
0
)
{
radix_line
(
" Compressed deviation pairs found:"
);
// Write compressed deviation pairs
stream
.
write
(
mData
->
deviationPairPresence
().
c_str
(),
30
);
stream
.
write
(
make_length
(
mData
->
deviationPairPresence
()
,
30
)
.
c_str
(),
30
);
// Add bytes written directly to eafstream count
stream
.
setBytesWritten
(
stream
.
bytesWritten
()
+
30
);
// Skip to 512 bytes (start of pairs)
stream
.
write
(
" "
,
512
-
stream
.
bytesWritten
());
stream
.
write
(
make_length
(
" "
,
512
-
stream
.
bytesWritten
()).
c_str
(),
512
-
stream
.
bytesWritten
());
// Add bytes written directly to eafstream count
stream
.
setBytesWritten
(
512
);
...
...
@@ -446,11 +456,22 @@ bool SpectrumPCFStream<data_type>::write_to(const std::string &file) const
}
radix_line
(
"|"
);
}
// Skip to 256*83 bytes (start of spectral data)
stream
.
write
(
make_length
(
" "
,
(
256
*
83
)
-
stream
.
bytesWritten
()).
c_str
(),
(
256
*
83
)
-
stream
.
bytesWritten
());
// Add bytes written directly to eafstream count
stream
.
setBytesWritten
(
256
*
83
);
}
else
{
// Don't write deviation pairs
radix_line
(
" No deviation pairs found:"
);
// Skip to 512 bytes (start of spectral data)
stream
.
write
(
make_length
(
" "
,
512
-
stream
.
bytesWritten
()).
c_str
(),
512
-
stream
.
bytesWritten
());
// Add bytes written directly to eafstream count
stream
.
setBytesWritten
(
512
);
}
// Write spectrum data
...
...
@@ -479,9 +500,9 @@ bool SpectrumPCFStream<data_type>::write_to(const std::string &file) const
char
delim
=
255
;
ss
<<
delim
<<
trim_string
(
title
)
<<
delim
<<
trim_string
(
description
)
<<
delim
<<
trim_string
(
source
);
stream
.
write
(
ss
.
str
().
c_str
(),
180
);
stream
.
write
(
dateTime
.
c_str
(),
23
);
stream
.
write
(
tag
.
c_str
(),
1
);
stream
.
write
(
make_length
(
ss
.
str
()
,
180
)
.
c_str
(),
180
);
stream
.
write
(
make_length
(
dateTime
,
23
)
.
c_str
(),
23
);
stream
.
write
(
make_length
(
tag
,
1
)
.
c_str
(),
1
);
// Add bytes written directly to eafstream count
stream
.
setBytesWritten
(
stream
.
bytesWritten
()
+
204
);
stream
.
writeFloat
(
liveTime
);
...
...
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