mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 03:10:02 +02:00

* initital implementation * datetime replaces with sls::Duration in Python C bindings * using custom type caster * fix for conversion to seconds * added set_count in python * common header for pybind11 includes authored-by: Erik Frojdh <erik.frojdh@psi.ch>
26 lines
562 B
C++
26 lines
562 B
C++
#include "DurationWrapper.h"
|
|
#include <cmath>
|
|
|
|
namespace sls{
|
|
|
|
DurationWrapper::DurationWrapper(double seconds){
|
|
ns_tick = std::round(seconds*1e9);
|
|
}
|
|
|
|
uint64_t DurationWrapper::count() const{
|
|
return ns_tick;
|
|
}
|
|
|
|
void DurationWrapper::set_count(uint64_t ns_count){
|
|
ns_tick = ns_count;
|
|
}
|
|
|
|
bool DurationWrapper::operator==(const DurationWrapper& other)const{
|
|
return ns_tick == other.ns_tick;
|
|
}
|
|
|
|
double DurationWrapper::total_seconds()const{
|
|
return static_cast<double>(ns_tick)/1e9;
|
|
}
|
|
|
|
} |