aboutsummaryrefslogtreecommitdiff
path: root/sensor
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-06-20 16:01:32 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-06-20 16:01:32 +0200
commitae42b9c012e10972eb1e666d9d17d4903940b906 (patch)
treebfc8d31b973004d73f1c5281508f4bf028df671e /sensor
parent46fa473b481191288e2ca6d9279e099b303af012 (diff)
downloadble-toys-ae42b9c012e10972eb1e666d9d17d4903940b906.tar.gz
ble-toys-ae42b9c012e10972eb1e666d9d17d4903940b906.tar.bz2
ble-toys-ae42b9c012e10972eb1e666d9d17d4903940b906.tar.xz
ble-toys-ae42b9c012e10972eb1e666d9d17d4903940b906.zip
o Adding a tool to add timestamps to each sample.
(old wip code)
Diffstat (limited to 'sensor')
-rw-r--r--sensor/include/trygvis/sensor.h9
-rw-r--r--sensor/main/sensor.cpp24
2 files changed, 33 insertions, 0 deletions
diff --git a/sensor/include/trygvis/sensor.h b/sensor/include/trygvis/sensor.h
index f8cfbe5..bcbd43b 100644
--- a/sensor/include/trygvis/sensor.h
+++ b/sensor/include/trygvis/sensor.h
@@ -29,6 +29,15 @@ std::ostream& operator<<(std::ostream& os, sample_format_type const& type);
std::istream& operator>>(std::istream& is, sample_format_type& type);
+enum class time_resolution {
+ SECONDS,
+ MILLISECONDS,
+};
+
+std::ostream& operator<<(std::ostream& os, time_resolution const& type);
+
+std::istream& operator>>(std::istream& is, time_resolution & type);
+
class sample_exception : public runtime_error {
public:
sample_exception(const string &what) : runtime_error(what) {
diff --git a/sensor/main/sensor.cpp b/sensor/main/sensor.cpp
index a773e0b..be3d31e 100644
--- a/sensor/main/sensor.cpp
+++ b/sensor/main/sensor.cpp
@@ -53,6 +53,30 @@ std::istream& operator>>(std::istream& is, sample_format_type& type) {
return is;
}
+std::ostream& operator<<(std::ostream& os, time_resolution const& type) {
+ if (type == time_resolution::SECONDS) {
+ os << "seconds";
+ } else if(type == time_resolution::MILLISECONDS) {
+ os << "milliseconds";
+ }
+
+ return os;
+}
+
+std::istream& operator>>(std::istream& is, time_resolution & type) {
+ string s;
+
+ is >> s;
+
+ if(s == "seconds") {
+ type = time_resolution::SECONDS;
+ } else if(s == "milliseconds") {
+ type = time_resolution::MILLISECONDS;
+ }
+
+ return is;
+}
+
template<>
const o<long> SampleRecord::lexical_at(const SampleKey *key) const {
auto value = at(key);