-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsiglent_data.cpp
More file actions
55 lines (40 loc) · 1.48 KB
/
siglent_data.cpp
File metadata and controls
55 lines (40 loc) · 1.48 KB
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
#include "siglent_data.hpp"
#include "siglent_bin.hpp"
#include <sstream>
std::vector<std::string> getAnalogLabes(const header_t& header)
{
std::vector<std::string> labels;
for (size_t ch = 0; ch < header.analog_ch_on.size(); ch++)
if (header.analog_ch_on[ch])
labels.push_back(std::to_string(ch + 1));
return labels;
}
std::vector<std::string> getDigitalLabes(const header_t& header)
{
std::vector<std::string> labels;
if (!header.digital_on)
return {};
for (size_t ch = 0; ch < header.digital_ch_on.size(); ch++)
if (header.digital_ch_on[ch])
labels.push_back(std::to_string(ch));
return labels;
}
std::string generateMetadata(const header_t& header, const std::vector<std::string>& analog_labels, const std::vector<std::string>& digital_labels)
{
std::stringstream metadata;
metadata << "[device 1]" << "\n"
<< "samplerate=" << (int)header.digital_sample_rate.get_value() << "\n";
if (digital_labels.size() > 0)
{
metadata << "total probes=" << digital_labels.size() << "\n";
metadata << "unitsize=2" << "\n";
metadata << "capturefile=logic-1" << "\n";
}
if (analog_labels.size() > 0)
metadata << "total analog=" << analog_labels.size() << "\n";
for (size_t i = 1; const auto& label : digital_labels)
metadata << "probe" << i++ << "=D" << label << "\n";
for (size_t i = digital_labels.size() + 1; const auto& label : analog_labels)
metadata << "analog" << i++ << "=A" << label << "\n";
return metadata.str();
}