-
Notifications
You must be signed in to change notification settings - Fork 0
/
NSxFile.h
65 lines (48 loc) · 1.64 KB
/
NSxFile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* NSxFile: Class for interacting with Ripple/Trellis NSx (continuous
data) files. Since these files are often huge (10s-100s of GB),
this mostly supports reading blocks of samples from the file into
memory
See also: NSxHeader (contains information about the whole file), and
NSxChannel (contains information about each channel)
*/
#pragma once
#ifndef NSXFILE_H_INCLUDED
#define NSXFILE_H_INCLUDED
#include <limits>
#include <stdexcept>
#include <vector>
#include "NSxHeader.h"
#include "NSxChannel.h"
#include "NSxConfig.h"
#ifdef MAT_FILE_SUPPORT
#include "MatFile.h"
#endif
class NSxFile {
public:
NSxFile(const std::string& filename);
size_t readData(std::uint32_t nSamples, int16_t* &buffer);
bool hasMoreData() const { return dataAvailable; }
NSxFile(const NSxFile &rhs) = delete;
NSxFile& operator=(NSxFile & rhs) = delete;
// Access to the header
#ifdef MAT_FILE_SUPPORT
void writeMatHeader(const NSxConfig &c);
#endif
void writeTxtHeader(const NSxConfig &c);
std::uint32_t getChannelCount() { return header.getChannelCount(); }
double getSamplingFreq() { return header.getSamplingFreq(); }
//Iterate over the channels
std::vector<NSxChannel>::const_iterator channelBegin() const;
std::vector<NSxChannel>::const_iterator channelEnd() const;
protected:
NSxHeader header;
std::vector<NSxChannel> channels;
std::ifstream file;
void prepareNextPacket();
std::uint32_t currentPacket;
std::uint32_t samplesRemainingInPacket;
bool dataAvailable;
std::uint32_t basetime;
private:
};
#endif /* defined(_NSxFile__) */