Commit c873ca7d authored by root's avatar root
Browse files

Merge branch 'devel' of https://github.com/TobiasWinchen/psrdada_cpp into devel

parents 61678df5 dde0e269
......@@ -27,6 +27,7 @@ class VDIFHeaderView
public:
VDIFHeaderView(const uint32_t* data);
void setDataLocation(const uint32_t* _data);
const uint32_t* getDataLocation() const;
uint32_t getVersionNumber() const;
bool isValid() const;
uint32_t getSecondsFromReferenceEpoch() const;
......@@ -54,6 +55,8 @@ class VDIFHeader : public VDIFHeaderView
public:
VDIFHeader();
VDIFHeader(const VDIFHeader &v);
VDIFHeader& operator=(const VDIFHeader& other);
// return pointer to the data block for low level manipulation
uint32_t* getData();
......
......@@ -50,6 +50,7 @@ VLBI<HandlerType>::VLBI(std::size_t buffer_bytes, std::size_t input_bitDepth,
<< _raw_voltage_db.size() << " 64-bit words,"
<< _raw_voltage_db.size() * 64 / 8 << " bytes";
_unpacked_voltage.resize(n64bit_words * 64 / input_bitDepth );
_packed_voltage.resize(n64bit_words * 64 / input_bitDepth * _output_bitDepth /
8);
......@@ -272,17 +273,22 @@ bool VLBI<HandlerType>::operator()(RawBytes &block) {
_spillOver.size(), cudaMemcpyDeviceToHost, _d2h_stream));
// fill in header data
const size_t samplesPerDataFrame = outputBlockSize * 8 / _output_bitDepth;
const size_t dataFramesPerSecond = _sampleRate / samplesPerDataFrame;
const uint32_t samplesPerDataFrame = outputBlockSize * 8 / _output_bitDepth;
const uint32_t dataFramesPerSecond = _sampleRate / samplesPerDataFrame;
for (size_t i = 0; i < numberOfBlocksInOutput; i++)
BOOST_LOG_TRIVIAL(debug) << " Samples per data frame: " << samplesPerDataFrame;
BOOST_LOG_TRIVIAL(debug) << " Dataframes per second: " << dataFramesPerSecond;
for (uint32_t i = 0; i < numberOfBlocksInOutput; i++)
{
// copy header to correct position
std::copy(reinterpret_cast<uint8_t *>(_vdifHeader.getData()),
// copy header to correct position
std::copy(reinterpret_cast<uint8_t *>(_vdifHeader.getData()),
reinterpret_cast<uint8_t *>(_vdifHeader.getData()) + vlbiHeaderSize,
_outputBuffer.a().begin() + i * (outputBlockSize + vlbiHeaderSize));
// update header
size_t dataFrame = _vdifHeader.getDataFrameNumber();
uint32_t dataFrame = _vdifHeader.getDataFrameNumber();
if (i < 5)
BOOST_LOG_TRIVIAL(debug) << i << " Dataframe Number: " << dataFrame;
if (dataFrame < dataFramesPerSecond)
{
_vdifHeader.setDataFrameNumber(dataFrame + 1);
......@@ -290,7 +296,7 @@ bool VLBI<HandlerType>::operator()(RawBytes &block) {
else
{
_vdifHeader.setDataFrameNumber(0);
_vdifHeader.setSecondsFromReferenceEpoch(_vdifHeader.getSecondsFromReferenceEpoch() + 1);
_vdifHeader.setSecondsFromReferenceEpoch(_vdifHeader.getSecondsFromReferenceEpoch() + 1);
}
}
......
......@@ -19,6 +19,10 @@ void VDIFHeaderView::setDataLocation(const uint32_t* _data) {
data = _data;
};
const uint32_t* VDIFHeaderView::getDataLocation() const {
return data;
};
bool VDIFHeaderView::isValid() const {
return (getBitsValue(data[0], 31, 31) == 0);
}
......@@ -91,6 +95,22 @@ VDIFHeader::VDIFHeader() : VDIFHeaderView(data)
setBitsWithValue(data[2], 29, 31, 1);
}
VDIFHeader::VDIFHeader(const VDIFHeader &v): VDIFHeaderView(data)
{
for (int i = 0; i < 8; i++) {
data[i] = v.getDataLocation()[i];
}
setDataLocation(data);
}
VDIFHeader& VDIFHeader::operator=(const VDIFHeader& other)
{
for (int i = 0; i < 8; i++) {
data[i] = other.getDataLocation()[i];
}
return *this;
}
uint32_t *VDIFHeader::getData() { return data; }
void VDIFHeader::setInvalid() { setBitsWithValue(data[0], 31, 31, 1); }
......
......@@ -120,6 +120,8 @@ class VDIF_Sender
//BOOST_LOG_TRIVIAL(debug) << counter << " Set delay to " << delay.count()<< " ns. Current rate " << current_rate << ", processed_bytes: " << processed_bytes;
}
if (counter < 5)
BOOST_LOG_TRIVIAL(debug) << counter << " Send - FN: " << vdifHeader.getDataFrameNumber() << ", Sec f. E.: " << vdifHeader.getSecondsFromReferenceEpoch() << " Get TS.: " << vdifHeader.getTimestamp();
}
BOOST_LOG_TRIVIAL(info) << "Send " << counter << " frames of " << block.used_bytes() << " bytes total size.";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment