forked from mutability/dump978
-
Notifications
You must be signed in to change notification settings - Fork 17
/
common.h
33 lines (24 loc) · 923 Bytes
/
common.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
// -*- c++ -*-
// Copyright (c) 2019, FlightAware LLC.
// All rights reserved.
// Licensed under the 2-clause BSD license; see the LICENSE file
#ifndef UAT_COMMON_H
#define UAT_COMMON_H
#ifndef VERSION
#define VERSION "unknown version compiled " __DATE__ " " __TIME__
#endif
#include <chrono>
#include <cmath>
#include <cstdint>
#include <vector>
namespace flightaware::uat {
typedef std::vector<std::uint8_t> Bytes;
typedef std::vector<std::uint16_t> PhaseBuffer;
inline static double RoundN(double value, unsigned dp) {
const double scale = std::pow(10, dp);
return std::round(value * scale) / scale;
}
const auto unix_epoch = std::chrono::system_clock::from_time_t(0);
inline static std::uint64_t now_millis() { return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - unix_epoch).count(); }
}; // namespace flightaware::uat
#endif