1
0
Fork 0
mirror of https://github.com/gwm17/DaqGrimoire.git synced 2024-11-23 03:08:52 -05:00

Redo file read api, to better facilitate time sorting multiple files.

This commit is contained in:
Gordon McCann 2022-09-29 19:59:07 -04:00
parent 09f1cf951c
commit 8f9b6a6246
2 changed files with 14 additions and 9 deletions

View File

@ -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

View File

@ -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; }
@ -104,7 +106,6 @@ namespace DaqGrimoire {
}
std::filesystem::path m_filepath;
std::shared_ptr<std::ifstream> 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;