DynExp
Highly flexible laboratory automation for dynamically changing experiments.
HardwareAdapterQutoolsTDC.cpp
Go to the documentation of this file.
1 // This file is part of DynExp.
2 
3 #include "stdafx.h"
5 
6 namespace 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 
35  {
37  { "Trigger on rising edge.", EdgeType::RisingEdge },
38  { "Trigger on falling edge.", EdgeType::FallingEdge }
39  };
40 
41  return List;
42  }
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 
58  const std::chrono::milliseconds Timeout)
59  {
61  }
62 
64  {
65  static QutoolsTDCSynchronizer Instance;
66 
67  return Instance;
68  }
69 
71  : Counts(std::move(Counts)), NumUpdates(NumUpdates)
72  {
73  HasBeenRead.resize(this->Counts.size(), false);
74  }
75 
78  {
79  Init();
80  }
81 
83  {
84  // Not locking, since the object is being destroyed. This should be inherently thread-safe.
85  CloseUnsafe();
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 
172  void QutoolsTDCHardwareAdapter::EnableHBT(bool Enable) const
173  {
174  auto TDCLock = QutoolsTDCSynchronizer::Lock();
176 
177  EnableHBTUnsafe(Enable);
178  }
179 
181  {
182  if (FirstChannel >= 31 || SecondChannel >= 31)
183  ThrowExceptionUnsafe(std::make_exception_ptr(Util::OutOfRangeException(
184  "Specify valid channels between 0 and 31.")));
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 
201  {
202  auto TDCLock = QutoolsTDCSynchronizer::Lock();
204 
205  ResetHBTUnsafe();
206  }
207 
208  QutoolsTDCSyms::Int64 QutoolsTDCHardwareAdapter::GetHBTEventCounts() const
209  {
210  auto TDCLock = QutoolsTDCSynchronizer::Lock();
212 
213  return GetHBTEventCountsUnsafe();
214  }
215 
216  std::chrono::microseconds QutoolsTDCHardwareAdapter::GetHBTIntegrationTime() const
217  {
218  auto TDCLock = QutoolsTDCSynchronizer::Lock();
220 
222  }
223 
225  {
226  auto TDCLock = QutoolsTDCSynchronizer::Lock();
228 
229  return GetHBTResultUnsafe();
230  }
231 
233  {
235 
236  return Timebase;
237  }
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(59);
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 >= 59)
291  ThrowExceptionUnsafe(std::make_exception_ptr(Util::OutOfRangeException(
292  "Specify a channel between 0 and 59.")));
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 
336  {
338 
339  OpenUnsafe();
340  }
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 
402  this->DeviceNumber = DeviceNumber;
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  ChannelCount = QutoolsTDCSyms::TDC_getChannelCount();
421 
422  SetTimestampBufferSizeUnsafe(TimestampBufferSize);
423  SetExposureTimeUnsafe(ExposureTime);
424  SetCoincidenceWindowUnsafe(CoincidenceWindow);
425  for (decltype(ChannelCount) i = 0; i < ChannelCount; ++i)
426  ConfigureSignalConditioningUnsafe(i, QutoolsTDCSyms::SCOND_MISC, UseRisingEdge, ThresholdInVolts);
427  }
428 
430  {
431  if (IsOpened())
432  {
433  // Handle now considered invalid, even if TDC_disconnect() fails.
434  DeviceConnected = false;
435 
436  auto Result = QutoolsTDCSyms::TDC_disconnect(DeviceNumber);
437  CheckError(Result);
438  }
439  }
440 
442  {
443  auto Result = QutoolsTDCSyms::TDC_addressDevice(DeviceNumber);
444  CheckError(Result);
445  }
446 
448  {
449  std::vector<QutoolsTDCSyms::Int64> Timestamps(BufferSize);
450  std::vector<ChannelType> Channels(BufferSize);
451  QutoolsTDCSyms::Int32 NumValid{};
452 
453  {
454  auto TDCLock = QutoolsTDCSynchronizer::Lock();
456 
457  auto Result = QutoolsTDCSyms::TDC_getLastTimestamps(true, Timestamps.data(), Channels.data(), &NumValid);
458  CheckError(Result);
459  } // TDCLock unlocked here.
460 
461  if (Timestamps.size() != Channels.size() || NumValid < 0 || NumValid > Timestamps.size())
462  ThrowExceptionUnsafe(std::make_exception_ptr(Util::InvalidDataException(
463  "Received invalid data from TDC_getLastTimestamps().")));
464 
465  for (size_t i = 0; i < NumValid; ++i)
466  TimestampsPerChannel[Channels[i]].push_back(ValueType(Timestamps[i]));
467  }
468 
469  // QutoolsTDCSynchronizer::Lock() and AddressThisTDCDeviceUnsafe() must be called manually before calling this function!
470  void QutoolsTDCHardwareAdapter::EnableChannelsUnsafe(bool EnableStartChannel, QutoolsTDCSyms::Int32 ChannelMask) const
471  {
472  auto Result = QutoolsTDCSyms::TDC_enableChannels(EnableStartChannel, ChannelMask);
473  CheckError(Result);
474  }
475 
476  // QutoolsTDCSynchronizer::Lock() and AddressThisTDCDeviceUnsafe() must be called manually before calling this function!
477  // First of pair denotes whether the start channel is enabled, second of pair denotes the mask of enabled channels.
478  std::pair<bool, QutoolsTDCSyms::Int32> QutoolsTDCHardwareAdapter::GetEnabledChannelsUnsafe() const
479  {
480  QutoolsTDCSyms::Bln32 StartEnabled{};
481  QutoolsTDCSyms::Int32 ChannelMask{};
482 
483  auto Result = QutoolsTDCSyms::TDC_getChannelsEnabled(&StartEnabled, &ChannelMask);
484  CheckError(Result);
485 
486  return std::make_pair(static_cast<bool>(StartEnabled), ChannelMask);
487  }
488 
489  void QutoolsTDCHardwareAdapter::SetExposureTimeUnsafe(std::chrono::milliseconds ExposureTime) const
490  {
491  auto Result = QutoolsTDCSyms::TDC_setExposureTime(Util::NumToT<QutoolsTDCSyms::Int32>(ExposureTime.count()));
492  CheckError(Result);
493  }
494 
496  {
497  auto Result = QutoolsTDCSyms::TDC_setCoincidenceWindow(Util::NumToT<QutoolsTDCSyms::Int32>(CoincidenceWindow / Timebase));
498  CheckError(Result);
499  }
500 
502  {
503  auto Result = QutoolsTDCSyms::TDC_setChannelDelay(Channel, Util::NumToT<QutoolsTDCSyms::Int32>(ChannelDelay.count()));
504  CheckError(Result);
505  }
506 
507  void QutoolsTDCHardwareAdapter::SetTimestampBufferSizeUnsafe(QutoolsTDCSyms::Int32 Size) const
508  {
509  auto Result = QutoolsTDCSyms::TDC_setTimestampBufferSize(Size);
510  CheckError(Result);
511 
512  BufferSize = Size;
513  }
514 
516  QutoolsTDCSyms::TDC_SignalCond Conditioning,bool UseRisingEdge, double ThresholdInVolts) const
517  {
518  auto Result = QutoolsTDCSyms::TDC_configureSignalConditioning(Channel, Conditioning, UseRisingEdge, ThresholdInVolts);
519  CheckError(Result);
520  }
521 
523  QutoolsTDCSyms::TDC_FilterType FilterType, QutoolsTDCSyms::Int32 ChannelMask) const
524  {
525  auto Result = QutoolsTDCSyms::TDC_configureFilter(Channel + 1, FilterType, ChannelMask);
526  CheckError(Result);
527  }
528 
530  {
531  auto Result = QutoolsTDCSyms::TDC_enableHbt(Enable);
532  CheckError(Result);
533  }
534 
536  {
537  auto Result = QutoolsTDCSyms::TDC_setHbtInput(FirstChannel + 1, SecondChannel + 1);
538  CheckError(Result);
539  }
540 
541  void QutoolsTDCHardwareAdapter::ConfigureHBTParamsUnsafe(Util::picoseconds BinWidth, QutoolsTDCSyms::Int32 BinCount) const
542  {
543  auto Result = QutoolsTDCSyms::TDC_setHbtParams(Util::NumToT<QutoolsTDCSyms::Int32>(BinWidth / Timebase), BinCount);
544  CheckError(Result);
545  }
546 
548  {
549  auto Result = QutoolsTDCSyms::TDC_resetHbtCorrelations();
550  CheckError(Result);
551  }
552 
554  {
555  QutoolsTDCSyms::Int64 TotalCount{}, LastCount{};
556  double LastRate{};
557 
558  auto Result = QutoolsTDCSyms::TDC_getHbtEventCount(&TotalCount, &LastCount, &LastRate);
559  CheckError(Result);
560 
561  return TotalCount;
562  }
563 
565  {
566  double IntegrationTime{};
567 
568  auto Result = QutoolsTDCSyms::TDC_getHbtIntegrationTime(&IntegrationTime);
569  CheckError(Result);
570 
571  return std::chrono::microseconds(static_cast<std::chrono::microseconds::rep>(std::round(IntegrationTime * std::micro::den)));
572  }
573 
575  {
576  auto HBTFunc = QutoolsTDCSyms::TDC_createHbtFunction();
577  if (!HBTFunc)
578  CheckError(TDC_Error);
579 
580  try
581  {
582  auto Result = QutoolsTDCSyms::TDC_calcHbtG2(HBTFunc);
583  CheckError(Result);
584 
585  HBTResultsType HBTResult;
586  for (decltype(HBTFunc->size) i = 0; i < HBTFunc->size; ++i)
587  HBTResult.emplace_back(HBTFunc->values[i], ((i - HBTFunc->indexOffset) * Timebase * HBTFunc->binWidth).count() / std::pico::den);
588 
589  QutoolsTDCSyms::TDC_releaseHbtFunction(HBTFunc);
590  HBTFunc = nullptr;
591 
592  return HBTResult;
593  }
594  catch (...)
595  {
596  if (HBTFunc)
597  QutoolsTDCSyms::TDC_releaseHbtFunction(HBTFunc);
598 
599  throw;
600  }
601  }
602 }
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.
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:224
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:163
Thrown when a requested ressource does not exist.
Definition: Exception.h:236
Thrown when an argument passed to a function exceeds the valid range.
Definition: Exception.h:211
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:625
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:762
std::string TrimTrailingZeros(const std::string &Str)
Removes trailing zeros ('\0') from a string.
Definition: Util.h:833
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.