mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-12-25 22:01:17 +01:00
Nanosecond times in Python (#522)
* 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>
This commit is contained in:
26
python/src/DurationWrapper.cpp
Normal file
26
python/src/DurationWrapper.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user