diff --git a/include/DYListData.h b/include/DYListData.h index 6aec970..36df8da 100644 --- a/include/DYListData.h +++ b/include/DYListData.h @@ -9,16 +9,18 @@ namespace DaqGrimoire { namespace Data { static constexpr std::size_t Size = 24; + static constexpr uint16_t InvalidBoard = 999; + static constexpr uint16_t InvalidChannel = 999; } struct DYListData { - uint16_t board; - uint16_t channel; - uint64_t timestamp; - uint32_t energy; - uint32_t energyShort; - uint32_t flags; + uint16_t board = Data::InvalidBoard; + uint16_t channel = Data::InvalidChannel; + uint64_t timestamp = 0; + uint32_t energy = 0; + uint32_t energyShort = 0; + uint32_t flags = 0; }; namespace Utils diff --git a/include/FileIO/DYFileReader.h b/include/FileIO/DYFileReader.h index 63ba01b..92a7a37 100644 --- a/include/FileIO/DYFileReader.h +++ b/include/FileIO/DYFileReader.h @@ -64,7 +64,7 @@ namespace DaqGrimoire { m_fileHandle->close(); } - bool GetNextEvent(DYListData& dataEvent) + bool ReadNextEvent() { if (!IsOpen() || IsEOF()) return false; @@ -76,11 +76,13 @@ namespace DaqGrimoire { return false; } - Utils::GetDataEventFromBuffer(m_bufferIter, dataEvent); + Utils::GetDataEventFromBuffer(m_bufferIter, m_dataEvent); return true; } + const DYListEvent& GetCurrentEvent() const { return m_dataEvent; } + const bool IsOpen() const { return m_fileHandle == nullptr ? false : m_fileHandle->is_open(); } const bool IsEOF() const { return m_isEOF; } @@ -103,7 +105,6 @@ namespace DaqGrimoire { m_bufferEnd = m_bufferIter + m_fileHandle->gcount(); //one past the last datum } - std::filesystem::path m_filepath; std::shared_ptr m_fileHandle; @@ -114,6 +115,8 @@ namespace DaqGrimoire { std::size_t m_fileSizeBytes; //in bytes std::size_t m_fileSizeEvents; //in data events + DYListData m_dataEvent; + bool m_isEOF; char* m_bufferIter;