mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
Merge branch 'developer' into apidhanya
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "TimeHelper.h"
|
||||
#include "ToString.h"
|
||||
#include "container_utils.h"
|
||||
|
||||
@ -30,6 +31,38 @@ template <class T, class Allocator = std::allocator<T>> class Result {
|
||||
Result() = default;
|
||||
Result(std::initializer_list<T> list) : vec(list){};
|
||||
|
||||
|
||||
/** Custom constructor from integer type to Result<ns> */
|
||||
template <typename V, typename = typename std::enable_if<
|
||||
std::is_integral<V>::value &&
|
||||
std::is_same<T, time::ns>::value>::type>
|
||||
Result(const std::vector<V> &from) {
|
||||
|
||||
vec.reserve(from.size());
|
||||
for (const auto &item : from)
|
||||
vec.push_back(T(item));
|
||||
}
|
||||
|
||||
/** Custom constructor from integer type to Result<ns> */
|
||||
template <typename V, typename = typename std::enable_if<
|
||||
std::is_integral<V>::value &&
|
||||
std::is_same<T, time::ns>::value>::type>
|
||||
Result(std::vector<V> &from) {
|
||||
vec.reserve(from.size());
|
||||
for (const auto &item : from)
|
||||
vec.push_back(T(item));
|
||||
}
|
||||
|
||||
/** Custom constructor from integer type to Result<ns> */
|
||||
template <typename V, typename = typename std::enable_if<
|
||||
std::is_integral<V>::value &&
|
||||
std::is_same<T, time::ns>::value>::type>
|
||||
Result(std::vector<V> &&from) {
|
||||
vec.reserve(from.size());
|
||||
for (const auto &item : from)
|
||||
vec.push_back(T(item));
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward arguments to the constructor of std::vector
|
||||
* @tparam Args template paramter pack to forward
|
||||
@ -82,9 +115,6 @@ template <class T, class Allocator = std::allocator<T>> class Result {
|
||||
|
||||
/** Convert Result<T> to std::vector<T> */
|
||||
operator std::vector<T>() { return vec; }
|
||||
|
||||
/** Convert Result<T> to T using squash() */
|
||||
operator T() { return squash(); }
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -51,9 +51,8 @@ Result<uint32_t> Detector::getRegister(uint32_t addr, Positions pos) {
|
||||
}
|
||||
|
||||
Result<ns> Detector::getExptime(Positions pos) const {
|
||||
auto r = pimpl->Parallel(&slsDetector::setTimer, pos,
|
||||
defs::ACQUISITION_TIME, -1);
|
||||
return Result<ns>(begin(r), end(r));
|
||||
return pimpl->Parallel(&slsDetector::setTimer, pos, defs::ACQUISITION_TIME,
|
||||
-1);
|
||||
}
|
||||
|
||||
Result<uint64_t> Detector::getStartingFrameNumber(Positions pos) const {
|
||||
@ -69,9 +68,8 @@ void Detector::setExptime(ns t, Positions pos) {
|
||||
}
|
||||
|
||||
Result<ns> Detector::getSubExptime(Positions pos) const {
|
||||
auto r = pimpl->Parallel(&slsDetector::setTimer, pos,
|
||||
defs::SUBFRAME_ACQUISITION_TIME, -1);
|
||||
return Result<ns>(begin(r), end(r));
|
||||
return pimpl->Parallel(&slsDetector::setTimer, pos,
|
||||
defs::SUBFRAME_ACQUISITION_TIME, -1);
|
||||
}
|
||||
|
||||
void Detector::setSubExptime(ns t, Positions pos) {
|
||||
@ -80,9 +78,7 @@ void Detector::setSubExptime(ns t, Positions pos) {
|
||||
}
|
||||
|
||||
Result<ns> Detector::getPeriod(Positions pos) const {
|
||||
auto r =
|
||||
pimpl->Parallel(&slsDetector::setTimer, pos, defs::FRAME_PERIOD, -1);
|
||||
return Result<ns>(begin(r), end(r));
|
||||
return pimpl->Parallel(&slsDetector::setTimer, pos, defs::FRAME_PERIOD, -1);
|
||||
}
|
||||
|
||||
void Detector::setPeriod(ns t, Positions pos) {
|
||||
|
Reference in New Issue
Block a user