DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
HardwareAdapterQutoolsTDC.cpp
Go to the documentation of this file.
1// This file is part of DynExp.
2
3#include "stdafx.h"
5
6namespace DynExpHardware
7{
8 // Returns the serial numbers of all available qutool TDC devices as a std::vector
9 // sorted by device number in ascending order.
11 {
12 unsigned int DeviceCount{};
13 auto Result = QutoolsTDCSyms::TDC_discover(&DeviceCount);
14 if (Result != TDC_Ok)
15 throw QutoolsTDCException("Error enumerating qutools TDC devices.", Result);
16
17 std::vector<std::string> DeviceDescriptors;
18 for (decltype(DeviceCount) i = 0; i < DeviceCount; ++i)
19 {
20 std::string DeviceName;
21 DeviceName.resize(32); // Must be at least 16 bytes (given by documentation of TDC_getDeviceInfo()).
22
23 Result = QutoolsTDCSyms::TDC_getDeviceInfo(i, nullptr, nullptr, DeviceName.data(), nullptr);
24 if (Result != TDC_Ok)
25 throw QutoolsTDCException("Error obtaining TDC device information.", Result);
26 DeviceName = Util::TrimTrailingZeros(DeviceName);
27
28 DeviceDescriptors.emplace_back(std::move(DeviceName));
29 }
30
31 return DeviceDescriptors;
32 }
33
43
45 {
46 auto QutoolsTDCDevices = QutoolsTDCHardwareAdapter::Enumerate();
47 if (!DeviceDescriptor.Get().empty() &&
48 std::find(QutoolsTDCDevices.cbegin(), QutoolsTDCDevices.cend(), DeviceDescriptor) == std::cend(QutoolsTDCDevices))
49 QutoolsTDCDevices.push_back(DeviceDescriptor);
50 if (QutoolsTDCDevices.empty())
51 throw Util::EmptyException("There is not any available qutools TDC device.");
52 DeviceDescriptor.SetTextList(std::move(QutoolsTDCDevices));
53
55 }
56
62
69
71 : Counts(std::move(Counts)), NumUpdates(NumUpdates)
72 {
73 HasBeenRead.resize(this->Counts.size(), false);
74 }
75
81
83 {
84 // Not locking, since the object is being destroyed. This should be inherently thread-safe.
86 }
87
88 void QutoolsTDCHardwareAdapter::EnableChannels(bool EnableStartChannel, QutoolsTDCSyms::Int32 ChannelMask) const
89 {
90 auto TDCLock = QutoolsTDCSynchronizer::Lock();
92
93 EnableChannelsUnsafe(EnableStartChannel, ChannelMask);
94 }
95
97 {
98 auto TDCLock = QutoolsTDCSynchronizer::Lock();
100
101 if (Channel >= ChannelCount)
102 ThrowExceptionUnsafe(std::make_exception_ptr(Util::OutOfRangeException(
103 "Specify a channel between 0 and " + Util::ToStr(ChannelCount))));
104
105 auto CurrentState = GetEnabledChannelsUnsafe();
106 EnableChannelsUnsafe(CurrentState.first, CurrentState.second | (1 << Channel));
107 }
108
110 {
111 auto TDCLock = QutoolsTDCSynchronizer::Lock();
113
114 if (Channel >= ChannelCount)
115 ThrowExceptionUnsafe(std::make_exception_ptr(Util::OutOfRangeException(
116 "Specify a channel between 0 and " + Util::ToStr(ChannelCount))));
117
118 auto CurrentState = GetEnabledChannelsUnsafe();
119 EnableChannelsUnsafe(CurrentState.first, CurrentState.second & ~(1 << Channel));
120 }
121
122 void QutoolsTDCHardwareAdapter::SetExposureTime(std::chrono::milliseconds ExposureTime) const
123 {
124 auto TDCLock = QutoolsTDCSynchronizer::Lock();
126
127 SetExposureTimeUnsafe(ExposureTime);
128 }
129
131 {
132 auto TDCLock = QutoolsTDCSynchronizer::Lock();
134
135 SetCoincidenceWindowUnsafe(CoincidenceWindow);
136 }
137
139 {
140 auto TDCLock = QutoolsTDCSynchronizer::Lock();
142
143 SetChannelDelayUnsafe(Channel, ChannelDelay);
144 }
145
146 void QutoolsTDCHardwareAdapter::SetTimestampBufferSize(QutoolsTDCSyms::Int32 Size) const
147 {
148 auto TDCLock = QutoolsTDCSynchronizer::Lock();
150
152 }
153
155 QutoolsTDCSyms::TDC_SignalCond Conditioning, bool UseRisingEdge, double ThresholdInVolts) const
156 {
157 auto TDCLock = QutoolsTDCSynchronizer::Lock();
159
160 ConfigureSignalConditioningUnsafe(Channel, Conditioning, UseRisingEdge, ThresholdInVolts);
161 }
162
163 void QutoolsTDCHardwareAdapter::ConfigureFilter(ChannelType Channel, QutoolsTDCSyms::TDC_FilterType FilterType,
164 QutoolsTDCSyms::Int32 ChannelMask) const
165 {
166 auto TDCLock = QutoolsTDCSynchronizer::Lock();
168
169 ConfigureFilterUnsafe(Channel, FilterType, ChannelMask);
170 }
171
173 {
174 auto TDCLock = QutoolsTDCSynchronizer::Lock();
176
177 EnableHBTUnsafe(Enable);
178 }
179
181 {
182 if (FirstChannel >= NumChannels || SecondChannel >= NumChannels)
183 ThrowExceptionUnsafe(std::make_exception_ptr(Util::OutOfRangeException(
184 "Specify valid channels between 0 and " + Util::ToStr(NumChannels) + ".")));
185
186 auto TDCLock = QutoolsTDCSynchronizer::Lock();
188
189 ConfigureHBTChannelsUnsafe(FirstChannel, SecondChannel);
190 }
191
192 void QutoolsTDCHardwareAdapter::ConfigureHBTParams(Util::picoseconds BinWidth, QutoolsTDCSyms::Int32 BinCount) const
193 {
194 auto TDCLock = QutoolsTDCSynchronizer::Lock();
196
197 ConfigureHBTParamsUnsafe(BinWidth, BinCount);
198 }
199
207
209 {
210 auto TDCLock = QutoolsTDCSynchronizer::Lock();
212
214 }
215
216 std::chrono::microseconds QutoolsTDCHardwareAdapter::GetHBTIntegrationTime() const
217 {
218 auto TDCLock = QutoolsTDCSynchronizer::Lock();
220
222 }
223
231
238
239 QutoolsTDCSyms::Int32 QutoolsTDCHardwareAdapter::GetBufferSize() const
240 {
242
243 return BufferSize;
244 }
245
246 // Extracts timestamp series for specific channel.
247 std::vector<QutoolsTDCHardwareAdapter::ValueType> QutoolsTDCHardwareAdapter::GetTimestamps(ChannelType Channel) const
248 {
250
252
253 auto Timestamps = TimestampsPerChannel.extract(Channel);
254 return !Timestamps.empty() ? std::move(Timestamps.mapped()) : std::vector<QutoolsTDCHardwareAdapter::ValueType>();
255 }
256
257 // Just sums up timestamp series for specific channel while keeping the series.
259 {
261
263
264 return TimestampsPerChannel[Channel].size();
265 }
266
268 {
269 auto TDCLock = QutoolsTDCSynchronizer::Lock();
271
272 // See documentation for TDC_getCoincCounters()
273 std::vector<QutoolsTDCSyms::Int32> Counts(NumCoincidenceChannels);
274 QutoolsTDCSyms::Int32 NumUpdates{};
275
276 auto Result = QutoolsTDCSyms::TDC_getCoincCounters(Counts.data(), &NumUpdates);
277 CheckError(Result);
278
279 if (NumUpdates)
280 CoincidenceData = { std::move(Counts), NumUpdates };
281
282 return CoincidenceData;
283 }
284
285 // First of pair denotes the coincidences of the specified channel (combination), second of pair denotes the number
286 // of updates the qutools TDC device has made since the last call to TDC_getCoincCounters().
287 std::pair<QutoolsTDCSyms::Int32, QutoolsTDCSyms::Int32> QutoolsTDCHardwareAdapter::GetCoincidenceCounts(ChannelType Channel) const
288 {
289 // See documentation for TDC_getCoincCounters()
290 if (Channel < 0 || Channel >= NumCoincidenceChannels)
291 ThrowExceptionUnsafe(std::make_exception_ptr(Util::OutOfRangeException(
292 "Specify a channel between 0 and " + Util::ToStr(NumCoincidenceChannels) + ".")));
293
295
296 // Just after CoincidenceData has been default-constructed, CoincidenceData.Counts is empty.
297 if (CoincidenceData.Counts.empty() || CoincidenceData.Counts.size() != CoincidenceData.HasBeenRead.size() || CoincidenceData.Counts.size() <= Channel)
298 return { 0, 0 };
299
300 auto RetVal = std::make_pair(CoincidenceData.Counts[Channel], CoincidenceData.HasBeenRead[Channel] ? 0 : CoincidenceData.NumUpdates);
301 CoincidenceData.HasBeenRead[Channel] = true;
302
303 return RetVal;
304 }
305
307 {
309
310 TimestampsPerChannel[Channel].clear();
311 }
312
314 {
315 DeviceConnected = false;
316 DeviceNumber = std::numeric_limits<decltype(DeviceNumber)>::max();
317 Timebase = ValueType(-1);
318 BufferSize = 0;
319 ChannelCount = 0;
320 TimestampsPerChannel.clear();
321 CoincidenceData = {};
322 }
323
325 {
326 // auto lock = AcquireLock(); not necessary here, since DynExp ensures that Object::Reset() can only
327 // be called if respective object is not in use.
328
329 CloseUnsafe();
330 Init();
331
333 }
334
341
343 {
345
346 auto Exception = GetExceptionUnsafe();
347 Util::ForwardException(Exception);
348
349 return IsOpened();
350 }
351
353 {
354 return IsOpened();
355 }
356
357 void QutoolsTDCHardwareAdapter::CheckError(const int Result, const std::source_location Location) const
358 {
359 if (Result == TDC_Ok)
360 return;
361
362 std::string ErrorString(QutoolsTDCSyms::TDC_perror(Result));
363
364 // AcquireLock() has already been called by an (in)direct caller of this function.
365 ThrowExceptionUnsafe(std::make_exception_ptr(QutoolsTDCException(std::move(ErrorString), Result, Location)));
366 }
367
369 {
370 if (IsOpened())
371 return;
372
373 std::ptrdiff_t DeviceNumber{ -1 };
374 QutoolsTDCSyms::Int32 TimestampBufferSize{};
375 bool UseRisingEdge{};
376 double ThresholdInVolts{};
377 std::chrono::milliseconds ExposureTime{};
378 ValueType CoincidenceWindow{};
379
380 {
381 auto DerivedParams = dynamic_Params_cast<QutoolsTDCHardwareAdapter>(GetParams());
382
383 auto DeviceSerials = Enumerate();
384 auto DeviceSerialIt = std::find(DeviceSerials.cbegin(), DeviceSerials.cend(), DerivedParams->DeviceDescriptor.Get());
385 DeviceNumber = std::distance(DeviceSerials.cbegin(), DeviceSerialIt);
386
387 if (DeviceNumber < 0 || Util::NumToT<size_t>(DeviceNumber) >= DeviceSerials.size())
388 {
389 std::string Serial = DeviceSerialIt == DeviceSerials.cend() ? "< unknown >" : *DeviceSerialIt;
390
391 ThrowExceptionUnsafe(std::make_exception_ptr(Util::NotFoundException(
392 "The qutools TDC device with serial " + Serial + " has not been found.")));
393 }
394
395 TimestampBufferSize = DerivedParams->DefaultTimestampBufferSize;
396 UseRisingEdge = DerivedParams->DefaultTriggerEdge == QutoolsTDCHardwareAdapterParams::EdgeType::RisingEdge;
397 ThresholdInVolts = DerivedParams->DefaultThresholdInVolts;
398 ExposureTime = std::chrono::milliseconds(DerivedParams->DefaultExposureTime);
399 CoincidenceWindow = ValueType(DerivedParams->DefaultCoincidenceWindow);
400 } // DerivedParams unlocked here.
401
403 auto Result = QutoolsTDCSyms::TDC_connect(this->DeviceNumber);
404 CheckError(Result);
405 DeviceConnected = true;
406
407 auto TDCLock = QutoolsTDCSynchronizer::Lock();
409
410 double Timebase{}; // in s
411 Result = QutoolsTDCSyms::TDC_getTimebase(&Timebase);
412 CheckError(Result);
413 this->Timebase = ValueType(Timebase * 1e12);
414
415 QutoolsTDCSyms::Int32 BufferSize{};
416 Result = QutoolsTDCSyms::TDC_getTimestampBufferSize(&BufferSize);
417 CheckError(Result);
418 this->BufferSize = BufferSize;
419
420#ifdef QUTOOLSQUTAG_VARIANT_S
421 ChannelCount = 5;
422#else
423 ChannelCount = QutoolsTDCSyms::TDC_getChannelCount();
424#endif
425
426 SetTimestampBufferSizeUnsafe(TimestampBufferSize);
427 SetExposureTimeUnsafe(ExposureTime);
428 SetCoincidenceWindowUnsafe(CoincidenceWindow);
429 for (decltype(ChannelCount) i = 0; i < ChannelCount; ++i)
430 ConfigureSignalConditioningUnsafe(i, QutoolsTDCSyms::SCOND_MISC, UseRisingEdge, ThresholdInVolts);
431 }
432
434 {
435 if (IsOpened())
436 {
437 // Handle now considered invalid, even if TDC_disconnect() fails.
438 DeviceConnected = false;
439
440 auto Result = QutoolsTDCSyms::TDC_disconnect(DeviceNumber);
441 CheckError(Result);
442 }
443 }
444
446 {
447 auto Result = QutoolsTDCSyms::TDC_addressDevice(DeviceNumber);
448 CheckError(Result);
449 }
450
452 {
453 std::vector<QutoolsTDCSyms::Int64> Timestamps(BufferSize);
454 std::vector<ChannelType> Channels(BufferSize);
455 QutoolsTDCSyms::Int32 NumValid{};
456
457 {
458 auto TDCLock = QutoolsTDCSynchronizer::Lock();
460
461 auto Result = QutoolsTDCSyms::TDC_getLastTimestamps(true, Timestamps.data(), Channels.data(), &NumValid);
462 CheckError(Result);
463 } // TDCLock unlocked here.
464
465 if (Timestamps.size() != Channels.size() || NumValid < 0 || NumValid > Timestamps.size())
466 ThrowExceptionUnsafe(std::make_exception_ptr(Util::InvalidDataException(
467 "Received invalid data from TDC_getLastTimestamps().")));
468
469 for (size_t i = 0; i < NumValid; ++i)
470 TimestampsPerChannel[Channels[i]].push_back(ValueType(Timestamps[i]));
471 }
472
473 // QutoolsTDCSynchronizer::Lock() and AddressThisTDCDeviceUnsafe() must be called manually before calling this function!
474 void QutoolsTDCHardwareAdapter::EnableChannelsUnsafe(bool EnableStartChannel, QutoolsTDCSyms::Int32 ChannelMask) const
475 {
476#ifdef QUTOOLSQUTAG_VARIANT_S
477 ChannelMask |= static_cast<decltype(ChannelMask)>(EnableStartChannel);
478 auto Result = QutoolsTDCSyms::TDC_enableChannels(ChannelMask);
479#else
480 auto Result = QutoolsTDCSyms::TDC_enableChannels(EnableStartChannel, ChannelMask);
481#endif
482 CheckError(Result);
483 }
484
485 // QutoolsTDCSynchronizer::Lock() and AddressThisTDCDeviceUnsafe() must be called manually before calling this function!
486 // First of pair denotes whether the start channel is enabled, second of pair denotes the mask of enabled channels.
487 std::pair<bool, QutoolsTDCSyms::Int32> QutoolsTDCHardwareAdapter::GetEnabledChannelsUnsafe() const
488 {
489 QutoolsTDCSyms::Bln32 StartEnabled{};
490 QutoolsTDCSyms::Int32 ChannelMask{};
491
492#ifdef QUTOOLSQUTAG_VARIANT_S
493 auto Result = QutoolsTDCSyms::TDC_getChannelsEnabled(&ChannelMask);
494 StartEnabled = ChannelMask & 1;
495#else
496 auto Result = QutoolsTDCSyms::TDC_getChannelsEnabled(&StartEnabled, &ChannelMask);
497#endif
498 CheckError(Result);
499
500 return std::make_pair(static_cast<bool>(StartEnabled), ChannelMask);
501 }
502
503 void QutoolsTDCHardwareAdapter::SetExposureTimeUnsafe(std::chrono::milliseconds ExposureTime) const
504 {
505 auto Result = QutoolsTDCSyms::TDC_setExposureTime(Util::NumToT<QutoolsTDCSyms::Int32>(ExposureTime.count()));
506 CheckError(Result);
507 }
508
510 {
511 auto Result = QutoolsTDCSyms::TDC_setCoincidenceWindow(Util::NumToT<QutoolsTDCSyms::Int32>(CoincidenceWindow / Timebase));
512 CheckError(Result);
513 }
514
516 {
517#ifdef QUTOOLSQUTAG_VARIANT_S
519 "The quTAG Standard does not support setting the channel delay.")));
520#else
521 auto Result = QutoolsTDCSyms::TDC_setChannelDelay(Channel, Util::NumToT<QutoolsTDCSyms::Int32>(ChannelDelay.count()));
522 CheckError(Result);
523#endif
524 }
525
526 void QutoolsTDCHardwareAdapter::SetTimestampBufferSizeUnsafe(QutoolsTDCSyms::Int32 Size) const
527 {
528 auto Result = QutoolsTDCSyms::TDC_setTimestampBufferSize(Size);
529 CheckError(Result);
530
531 BufferSize = Size;
532 }
533
535 QutoolsTDCSyms::TDC_SignalCond Conditioning,bool UseRisingEdge, double ThresholdInVolts) const
536 {
537 auto Result = QutoolsTDCSyms::TDC_configureSignalConditioning(Channel, Conditioning, UseRisingEdge, ThresholdInVolts);
538 CheckError(Result);
539 }
540
542 QutoolsTDCSyms::TDC_FilterType FilterType, QutoolsTDCSyms::Int32 ChannelMask) const
543 {
544 auto Result = QutoolsTDCSyms::TDC_configureFilter(Channel + 1, FilterType, ChannelMask);
545
546 if (Result == TDC_NotAvailable)
547 SetWarning("The TDC_configureFilter() function is not available on this quTag device.", Util::DynExpErrorCodes::NotAvailable);
548 else
549 CheckError(Result);
550 }
551
553 {
554 auto Result = QutoolsTDCSyms::TDC_enableHbt(Enable);
555 CheckError(Result);
556 }
557
559 {
560 auto Result = QutoolsTDCSyms::TDC_setHbtInput(FirstChannel + 1, SecondChannel + 1);
561 CheckError(Result);
562 }
563
564 void QutoolsTDCHardwareAdapter::ConfigureHBTParamsUnsafe(Util::picoseconds BinWidth, QutoolsTDCSyms::Int32 BinCount) const
565 {
566 auto Result = QutoolsTDCSyms::TDC_setHbtParams(Util::NumToT<QutoolsTDCSyms::Int32>(BinWidth / Timebase), BinCount);
567 CheckError(Result);
568 }
569
571 {
572 auto Result = QutoolsTDCSyms::TDC_resetHbtCorrelations();
573 CheckError(Result);
574 }
575
577 {
578 QutoolsTDCSyms::Int64 TotalCount{}, LastCount{};
579 double LastRate{};
580
581 auto Result = QutoolsTDCSyms::TDC_getHbtEventCount(&TotalCount, &LastCount, &LastRate);
582 CheckError(Result);
583
584 return TotalCount;
585 }
586
588 {
589 double IntegrationTime{};
590
591 auto Result = QutoolsTDCSyms::TDC_getHbtIntegrationTime(&IntegrationTime);
592 CheckError(Result);
593
594 return std::chrono::microseconds(static_cast<std::chrono::microseconds::rep>(std::round(IntegrationTime * std::micro::den)));
595 }
596
598 {
599 auto HBTFunc = QutoolsTDCSyms::TDC_createHbtFunction();
600 if (!HBTFunc)
601 CheckError(TDC_Error);
602
603 try
604 {
605 auto Result = QutoolsTDCSyms::TDC_calcHbtG2(HBTFunc);
606 CheckError(Result);
607
608 HBTResultsType HBTResult;
609 for (decltype(HBTFunc->size) i = 0; i < HBTFunc->size; ++i)
610 HBTResult.emplace_back(HBTFunc->values[i], ((i - HBTFunc->indexOffset) * Timebase * HBTFunc->binWidth).count() / std::pico::den);
611
612 QutoolsTDCSyms::TDC_releaseHbtFunction(HBTFunc);
613 HBTFunc = nullptr;
614
615 return HBTResult;
616 }
617 catch (...)
618 {
619 if (HBTFunc)
620 QutoolsTDCSyms::TDC_releaseHbtFunction(HBTFunc);
621
622 throw;
623 }
624 }
625}
Implementation of a hardware adapter to control qutools TDC hardware.
static Util::TextValueListType< EdgeType > EdgeTypeStrList()
void ConfigureParamsImpl(dispatch_tag< HardwareAdapterParamsBase >) override final
Only one instance of this class is allowed for synchronizing calls to connected qutools time taggers....
static LockType Lock(const std::chrono::milliseconds Timeout=std::chrono::milliseconds(100))
QutoolsTDCHardwareAdapter(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
void ConfigureFilterUnsafe(ChannelType Channel, QutoolsTDCSyms::TDC_FilterType FilterType=QutoolsTDCSyms::TDC_FilterType::FILTER_NONE, QutoolsTDCSyms::Int32 ChannelMask=0) const
bool IsConnectedChild() const noexcept override final
Determines the connection status of the hardware interface.
const CoincidenceDataType & GetCoincidenceCounts() const
void SetExposureTime(std::chrono::milliseconds ExposureTime) const
void ConfigureSignalConditioningUnsafe(ChannelType Channel, QutoolsTDCSyms::TDC_SignalCond Conditioning=QutoolsTDCSyms::SCOND_MISC, bool UseRisingEdge=true, double ThresholdInVolts=1) const
void SetTimestampBufferSize(QutoolsTDCSyms::Int32 Size) const
void EnableChannels(bool EnableStartChannel, QutoolsTDCSyms::Int32 ChannelMask) const
void SetCoincidenceWindow(ValueType CoincidenceWindow) const
void SetExposureTimeUnsafe(std::chrono::milliseconds ExposureTime) const
std::pair< bool, QutoolsTDCSyms::Int32 > GetEnabledChannelsUnsafe() const
void ConfigureFilter(ChannelType Channel, QutoolsTDCSyms::TDC_FilterType FilterType=QutoolsTDCSyms::TDC_FilterType::FILTER_NONE, QutoolsTDCSyms::Int32 ChannelMask=0) const
std::chrono::microseconds GetHBTIntegrationTime() const
void ConfigureSignalConditioning(ChannelType Channel, QutoolsTDCSyms::TDC_SignalCond Conditioning=QutoolsTDCSyms::SCOND_MISC, bool UseRisingEdge=true, double ThresholdInVolts=1) const
bool IsReadyChild() const override final
Returns wheter this Object instance is ready (e.g. it is running or connected to a hardware device) a...
void SetChannelDelayUnsafe(ChannelType Channel, Util::picoseconds ChannelDelay) const
void CheckError(const int Result, const std::source_location Location=std::source_location::current()) const
void ConfigureHBTParamsUnsafe(Util::picoseconds BinWidth, QutoolsTDCSyms::Int32 BinCount) const
void ResetImpl(dispatch_tag< HardwareAdapterBase >) override final
std::chrono::microseconds GetHBTIntegrationTimeUnsafe() const
DynExpInstr::TimeTaggerData::HBTResultsType::ResultVectorType HBTResultsType
void SetCoincidenceWindowUnsafe(ValueType CoincidenceWindow) const
void SetTimestampBufferSizeUnsafe(QutoolsTDCSyms::Int32 Size) const
void EnsureReadyStateChild() override final
Ensures that this Object instance is ready by possibly starting its worker thread or by opening conne...
void ConfigureHBTParams(Util::picoseconds BinWidth, QutoolsTDCSyms::Int32 BinCount) const
void ConfigureHBTChannelsUnsafe(ChannelType FirstChannel, ChannelType SecondChannel) const
void EnableChannelsUnsafe(bool EnableStartChannel, QutoolsTDCSyms::Int32 ChannelMask) const
void SetChannelDelay(ChannelType Channel, Util::picoseconds ChannelDelay) const
void ConfigureHBTChannels(ChannelType FirstChannel, ChannelType SecondChannel) const
std::unordered_map< ChannelType, std::vector< ValueType > > TimestampsPerChannel
size_t GetCountsFromTimestamps(ChannelType Channel) const
std::vector< ValueType > GetTimestamps(ChannelType Channel) const
HardwareAdapterBase(const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params)
Constructs a hardware adapter instance.
static constexpr auto HardwareOperationTimeout
Default timeout used to lock the mutex provided by the base class Util::ILockable to synchronize acce...
void ThrowExceptionUnsafe(std::exception_ptr Exception) const
Stores Exception in LastException, wraps it in a Util::ForwardedException and throws the wrapped exce...
auto GetExceptionUnsafe() const
Getter for LastException.
void SetWarning(std::string Description, int ErrorCode) const
Setter for Object::Warning. Sets the warning by a description and an error code.
Definition Object.cpp:454
ParamsConstTypeSyncPtrType GetParams(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
Locks the mutex of the parameter class instance Params assigned to this Object instance and returns a...
Definition Object.cpp:436
const std::thread::id OwnerThreadID
Thread id of the thread which has constructed (and owns) this Object instance.
Definition Object.h:2302
const ParamsBasePtrType Params
Pointer to the parameter class instance belonging to this Object instance.
Definition Object.h:2303
Refer to ParamsBase::dispatch_tag.
Definition Object.h:2018
Tag for function dispatching mechanism within this class used when derived classes are not intended t...
Definition Object.h:349
Thrown when a list is expected to contain entries and when a query results in an empty answer or an e...
Definition Exception.h:225
LockType AcquireLock(const std::chrono::milliseconds Timeout=DefaultTimeout) const
Locks the internal mutex. Blocks until the mutex is locked or until the timeout duration is exceeded.
Definition Util.cpp:8
std::unique_lock< MutexType > LockType
Definition Util.h:66
Data to operate on is invalid for a specific purpose. This indicates a corrupted data structure or fu...
Definition Exception.h:164
Thrown when a requested ressource does not exist.
Definition Exception.h:237
Thrown when a requested feature is either under development and thus not implemented yet or when a sp...
Definition Exception.h:300
Thrown when an argument passed to a function exceeds the valid range.
Definition Exception.h:212
DynExp's hardware namespace contains the implementation of DynExp hardware adapters which extend DynE...
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
Definition Object.h:1807
std::string ToStr(const T &Value, int Precision=-1)
Converts a (numeric) value of type T to a std::string using operator<< of std::stringstream.
Definition Util.h:688
void ForwardException(std::exception_ptr e)
Wraps the exception passed to the function in a ForwardedException and throws the ForwardedException....
Definition Exception.cpp:30
std::chrono::duration< double, std::pico > picoseconds
Extends std::chrono by a duration data type for picoseconds.
Definition Util.h:622
std::string TrimTrailingZeros(const std::string &Str)
Removes trailing zeros ('\0') from a string.
Definition Util.h:893
std::vector< std::pair< TextType, ValueType > > TextValueListType
Type of a list containing key-value pairs where key is a text of type Util::TextType.
Definition QtUtil.h:37
Accumulates include statements to provide a precompiled header.