obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but that tree was gitignored, so a clone of this repository could not build the firmware it ships. It is now committed here as ordinary files in its own folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP bridge's signature verification (--trust) used on the bench. Nothing is fetched from or pushed to the colleague's repository; this repository and its remotes carry everything. The folder's own .gitignore keeps build output, downloaded components and private key material out, as it did there; the committed file set is identical to that repository's tracked files. The ESP32-C5 is still flashed from obu-firmware/, which only takes vanetza-idf from microbu-esp32c5/, so the two stay separate folders. FLASHING.md says how to take a newer version of the colleague's tree (copy it over the folder, rebuild, test, commit).
82 lines
2.4 KiB
C++
82 lines
2.4 KiB
C++
#ifndef TIMESTAMP_HPP_SFETMZJI
|
|
#define TIMESTAMP_HPP_SFETMZJI
|
|
|
|
#include <vanetza/common/clock.hpp>
|
|
#include <vanetza/geonet/serialization.hpp>
|
|
#include <cstdint>
|
|
#include <boost/operators.hpp>
|
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
|
#include <boost/units/absolute.hpp>
|
|
#include <boost/units/quantity.hpp>
|
|
#include <boost/units/systems/si/time.hpp>
|
|
#include <boost/units/make_scaled_unit.hpp>
|
|
|
|
namespace vanetza
|
|
{
|
|
namespace geonet
|
|
{
|
|
|
|
class Timestamp : public boost::totally_ordered<Timestamp>
|
|
{
|
|
public:
|
|
typedef uint32_t value_type;
|
|
typedef boost::units::make_scaled_unit<
|
|
boost::units::si::time,
|
|
boost::units::scale<10, boost::units::static_rational<-3>>
|
|
>::type unit_type;
|
|
typedef boost::units::absolute<unit_type> absolute_unit_type;
|
|
typedef boost::units::quantity<absolute_unit_type, value_type> time_type;
|
|
typedef boost::units::quantity<unit_type, value_type> duration_type;
|
|
|
|
static unit_type millisecond();
|
|
static boost::posix_time::ptime start_time();
|
|
|
|
Timestamp() : m_timestamp(0) {}
|
|
Timestamp(time_type t) : m_timestamp(t) {}
|
|
Timestamp(const Clock::time_point&);
|
|
Timestamp(const boost::posix_time::ptime&);
|
|
value_type raw() const { return m_timestamp.value(); }
|
|
time_type quantity() const { return m_timestamp; }
|
|
Timestamp& operator+=(duration_type);
|
|
Timestamp& operator-=(duration_type);
|
|
|
|
/**
|
|
* Timestamp is before other one
|
|
* \param other time stamp
|
|
* \return true if other timestamp is later
|
|
*/
|
|
bool before(const Timestamp& other) const;
|
|
|
|
/**
|
|
* Timestamp is after other one
|
|
* \param other time stamp
|
|
* \return true is other timestamp is before
|
|
*/
|
|
bool after(const Timestamp& other) const;
|
|
|
|
private:
|
|
time_type m_timestamp; // since 01-01-2004 00:00:00.0
|
|
};
|
|
|
|
// timestamp calculus
|
|
Timestamp operator+(Timestamp lhs, Timestamp::duration_type rhs);
|
|
Timestamp operator-(Timestamp lhs, Timestamp::duration_type rhs);
|
|
Timestamp::duration_type operator-(Timestamp lhs, Timestamp rhs);
|
|
|
|
// timestamp comparison according to ETSI GeoNet
|
|
bool is_greater(Timestamp lhs, Timestamp rhs);
|
|
|
|
// operators required for boost::totally_ordered
|
|
bool operator<(Timestamp lhs, Timestamp rhs);
|
|
bool operator==(Timestamp lhs, Timestamp rhs);
|
|
|
|
// serialization
|
|
void serialize(const Timestamp&, OutputArchive&);
|
|
void deserialize(Timestamp&, InputArchive&);
|
|
|
|
} // namespace geonet
|
|
} // namespace vanetza
|
|
|
|
#endif /* TIMESTAMP_HPP_SFETMZJI */
|
|
|