mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 23:37:14 +02: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.h
Normal file
26
python/src/DurationWrapper.h
Normal file
@ -0,0 +1,26 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace sls{
|
||||
/*
|
||||
Wrapper for nanoseconds stored in uint64_t, used for conversion between
|
||||
std::chrono::nanoseconds and python (float or sls::DurationWrapper)
|
||||
*/
|
||||
|
||||
class DurationWrapper{
|
||||
uint64_t ns_tick{0};
|
||||
|
||||
public:
|
||||
DurationWrapper() = default;
|
||||
explicit DurationWrapper(double seconds);
|
||||
~DurationWrapper() = default;
|
||||
|
||||
bool operator==(const DurationWrapper& other) const;
|
||||
uint64_t count() const;
|
||||
void set_count(uint64_t count);
|
||||
double total_seconds() const;
|
||||
};
|
||||
|
||||
}
|
Reference in New Issue
Block a user