DynExp
Highly flexible laboratory automation for dynamically changing experiments.
main.cpp.in
Go to the documentation of this file.
1 // This file is part of DynExp.
2 
23 #include "stdafx.h"
24 #include "DynExpManager.h"
25 #include <QtWidgets/QApplication>
26 
33 #cmakedefine USE_NIDAQ
34 #cmakedefine USE_PVCAM
35 #cmakedefine USE_QUTOOLSQUTAG
36 #cmakedefine USE_SMARACT
37 #cmakedefine USE_SWABIANPULSESTREAMER
38 #cmakedefine USE_ZIMFLI
40 
41 // Hardware adapters
44 
45 // Instruments
57 #include "Instruments/PI-C-862.h"
58 #include "Instruments/RS_SMB100B.h"
59 #include "Instruments/RS_SMC100A.h"
61 #ifdef USE_NIDAQ
66 #endif // USE_NIDAQ
67 #ifdef USE_PVCAM
68 #include "Instruments/PVCam.h"
69 #endif // USE_PVCAM
70 #ifdef USE_QUTOOLSQUTAG
72 #endif // USE_QUTOOLSQUTAG
73 #ifdef USE_SMARACT
74 #include "Instruments/SmarAct.h"
75 #endif // USE_SMARACT
76 #ifdef USE_SWABIANPULSESTREAMER
78 #endif // USE_SWABIANPULSESTREAMER
79 #ifdef USE_ZIMFLI
80 #include "Instruments/ZI_MFLI.h"
81 #endif // USE_ZIMFLI
82 
83 // Modules
95 #include "Modules/SignalDesigner.h"
96 #include "Modules/SignalPlotter.h"
98 #include "Modules/Stage1D.h"
100 #include "Modules/Trajectory1D.h"
101 
102 // Experiment modules
104 #include "Modules/ODMR/ODMR.h"
105 
114 int main(int argc, char *argv[])
115 {
119 #ifdef USE_NIDAQ
121 #endif // USE_NIDAQ
122 #ifdef USE_PVCAM
124 #endif // USE_PVCAM
125 #ifdef USE_QUTOOLSQUTAG
127 #endif // USE_QUTOOLSQUTAG
128 #ifdef USE_SMARACT
130 #endif // USE_SMARACT
131 #ifdef USE_SWABIANPULSESTREAMER
133 #endif // USE_SWABIANPULSESTREAMER
134 #ifdef USE_ZIMFLI
136 #endif // USE_ZIMFLI
137  > HardwareAdapterLib;
138 
139  constexpr DynExp::InstrumentLibrary<
155 #ifdef USE_NIDAQ
160 #endif // USE_NIDAQ
161 #ifdef USE_PVCAM
163 #endif // USE_PVCAM
164 #ifdef USE_QUTOOLSQUTAG
166 #endif // USE_QUTOOLSQUTAG
167 #ifdef USE_SMARACT
169 #endif // USE_SMARACT
170 #ifdef USE_SWABIANPULSESTREAMER
172 #endif // USE_SWABIANPULSESTREAMER
173 #ifdef USE_ZIMFLI
175 #endif // USE_ZIMFLI
176  > InstrumentLib;
177 
178  constexpr DynExp::ModuleLibrary<
196  //
197  // Experiments
200  > ModuleLib;
201 
202  int ErrorReturnCode = Util::DynExpErrorCodes::GeneralError;
203  try
204  {
205  // Set up language and application settings.
206  std::locale::global(std::locale(std::locale(DynExp::DefaultLocale), new DynExp::DefaultLocaleSeparator));
207  QLocale::setDefault(Util::GetDefaultQtLocale());
208 
209  QApplication App(argc, argv);
210  QApplication::setApplicationName(DynExp::DynExpName);
211  QApplication::setApplicationVersion(DynExp::DynExpVersion);
212 
213  // Turn off GSL error handler.
214  gsl_set_error_handler_off();
215 
216  // Initialize Python interpreter.
217  Util::PyGilReleasedInterpreter PyInterpreter;
218 
219  // Parse command line options.
220  QCommandLineParser Parser;
221  Parser.setApplicationDescription(DynExp::DynExpDescription);
222  Parser.addHelpOption();
223  Parser.addVersionOption();
224  Parser.addPositionalArgument("file", "Project file (*.dynp) to open.");
225  Parser.process(App);
226 
227  QString ProjectFile;
228  if (!Parser.positionalArguments().empty())
229  ProjectFile = Parser.positionalArguments()[0];
230 
231  // Initialize DynExp.
232  auto DynExpCore = std::make_unique<DynExp::DynExpCore>(HardwareAdapterLib.ToVector(), InstrumentLib.ToVector(), ModuleLib.ToVector(),
233  ProjectFile.toStdString());
234  auto DynExpMgr = std::make_unique<DynExpManager>(*DynExpCore);
235  DynExpMgr->showMaximized();
236 
237 #ifdef DYNEXP_DEBUG
238  PyInterpreter.PrintDebugInfo();
239 #endif // DYNEXP_DEBUG
240 
241  // All exceptions need to be caught in Qt event handlers. Exceptions leaving slots is considered undefined behaviour.
242  // The exception does not propagate here! See https://doc.qt.io/qt-5/exceptionsafety.html
243  return App.exec();
244  }
245  catch (const Util::Exception& e)
246  {
247  Util::EventLog().Log(e);
248  ErrorReturnCode = e.ErrorCode;
249 
250 #ifdef DYNEXP_DEBUG
251  throw;
252 #endif // DYNEXP_DEBUG
253  }
254  catch (const std::exception& e)
255  {
256  Util::EventLog().Log(e.what(), Util::ErrorType::Fatal, ErrorReturnCode);
257 
258 #ifdef DYNEXP_DEBUG
259  throw;
260 #endif // DYNEXP_DEBUG
261  }
262  catch (...)
263  {
264  Util::EventLog().Log("Unknown Error", Util::ErrorType::Fatal, ErrorReturnCode);
265 
266 #ifdef DYNEXP_DEBUG
267  throw;
268 #endif // DYNEXP_DEBUG
269  }
270 
271  return ErrorReturnCode;
272 }
Implementation of a module to read a waveform from a CSV file and to store it in a data stream of a f...
Implementation of a camera instrument without any related physical hardware loading image files from ...
Implementation of a data stream instrument without any related physical hardware.
Implements DynExp's main UI window called DynExpManager.
Implementation of a hardware adapter to communicate text-based commands over TCP sockets.
Implementation of a hardware adapter to communicate text-based commands over COM ports.
Implementation of a module to display images recorded by camera instruments.
Implementation of a module to read single values from input port instruments.
Implementation of the inter-module communicator instrument to exchange events in between DynExp modul...
Implementation of a module to control a lock-in amplifier.
Implementation of an instrument to control a single analog input of the National Instruments NIDAQmx ...
Implementation of an instrument to control a single analog output of the National Instruments NIDAQmx...
Implementation of an instrument to control a single digital input of the National Instruments NIDAQmx...
Implementation of an instrument to control a single digital output of the National Instruments NIDAQm...
Implementation of an instrument to control the positioner stage of the Nenion Leakvalve F3 valve.
Implementation of a gRPC client instrument to access a remote analog in meta instrument.
Implementation of a gRPC server module to provide remote access to an analog in meta instrument.
Implementation of a gRPC client instrument to access a remote analog out meta instrument.
Implementation of a gRPC server module to provide remote access to an analog out meta instrument.
Implementation of a gRPC server module to provide remote access to a data stream instrument meta inst...
Implementation of a gRPC client instrument to access a remote data stream meta instrument.
Implementation of a gRPC client instrument to access a remote digital in meta instrument.
Implementation of a gRPC server module to provide remote access to a digital in meta instrument.
Implementation of a gRPC client instrument to access a remote digital out meta instrument.
Implementation of a gRPC server module to provide remote access to a digital out meta instrument.
Implementation of a gRPC client instrument to access a remote spectrometer meta instrument.
Implementation of a gRPC server module to provide remote access to a time tagger meta instrument.
Implementation of a gRPC client instrument to access a remote time tagger meta instrument.
Implementation of a module to perform optically detected magnetic resonance (ODMR) measurements.
Implementation of a module to write single values to output port instruments.
Implementation of an instrument to control the Physik Instrumente (PI) C-862 positioner stage.
Implementation of an instrument to control Teledyne Photometrics PVCam cameras.
Implementation of an instrument to control a single input of the qutools TDC time tagger.
Implementation of an instrument to control the Rohde & Schwarz SMB100B function generator.
Implementation of an instrument to control the Rohde & Schwarz SMC100A function generator.
Implementation of a module to design waveforms and to store them in data streams of function generato...
Implementation of a module to plot the samples stored in data stream instruments.
Implementation of an instrument to control a single positioner stage connected to the SmarAct MCS2.
Implementation of a module to plot the spectrum stored in a spectrometer instrument.
Implementation of a module to control a 1D positioner stage.
Implementation of a module to process data stored in data stream instrument(s) with a Python script a...
Implementation of an instrument to control a single output of the Swabian Instruments Pulse Streamer ...
Implementation of a module to interpret samples stored in a data stream instrument as trajectories of...
Implementation of a gRPC client instrument to access a remote service for image processing (localizat...
Implementation of a module to control a combined widefield and confocal microscope.
Implementation of an instrument to control the Zurich Instruments MFLI lock-in amplifier.
Defines an inter-module communicator instrument to exchange events in between DynExp modules....
Module to process data stored in data stream instrument(s) with a Python script and to write the resu...
Represents a hardware adapter library to generate instances of classes derived from DynExp::HardwareA...
Definition: Libraries.h:199
Implements a hardware adapter to communicate with text-based commands over COM ports.
Implements a hardware adapter to communicate with text-based commands over TCP sockets.
Represents an instrument library to generate instances of classes derived from DynExp::InstrumentBase...
Definition: Libraries.h:220
Represents a module library to generate instances of classes derived from DynExp::ModuleBase.
Definition: Libraries.h:241
void Log(const std::string &Message, const ErrorType Type=ErrorType::Info, const size_t Line=0, const std::string &Function="", const std::string &File="", const int ErrorCode=0, const std::stacktrace &Trace={}) noexcept
Logs an event from information specified manually.
Definition: Util.cpp:309
DynExp exceptions are derived from this class. It contains basic information about the cause of the e...
Definition: Exception.h:51
const int ErrorCode
DynExp error code from DynExpErrorCodes::DynExpErrorCodes
Definition: Exception.h:106
Initialize Python interpreter and directly release the GIL after construction.
Definition: PyUtil.h:43
void PrintDebugInfo()
Writes information on the Python interpreter configuration to DynExp's log.
Definition: PyUtil.cpp:51
int main(int argc, char *argv[])
DynExpManager's main entry point
Definition: main.cpp.in:114
NetworkDigitalInT< DigitalIn, 0, typename NetworkDataStreamInstrument::StubType, DynExpProto::NetworkDigitalIn::NetworkDigitalIn > NetworkDigitalIn
Explicit instantiation of derivable class NetworkDigitalInT to create the network digital in instrume...
NetworkDigitalOutT< DigitalOut, 0, typename NetworkDataStreamInstrument::StubType, DynExpProto::NetworkDigitalOut::NetworkDigitalOut > NetworkDigitalOut
Explicit instantiation of derivable class NetworkDigitalOutT to create the network digital out instru...
NetworkAnalogInT< AnalogIn, 0, typename NetworkDataStreamInstrument::StubType, DynExpProto::NetworkAnalogIn::NetworkAnalogIn > NetworkAnalogIn
Explicit instantiation of derivable class NetworkAnalogInT to create the network analog in instrument...
NetworkTimeTaggerT< TimeTagger, 0, typename NetworkDataStreamInstrument::StubType, DynExpProto::NetworkTimeTagger::NetworkTimeTagger > NetworkTimeTagger
Explicit instantiation of derivable class NetworkTimeTaggerT to create the network time tagger instru...
NetworkAnalogOutT< AnalogOut, 0, typename NetworkDataStreamInstrument::StubType, DynExpProto::NetworkAnalogOut::NetworkAnalogOut > NetworkAnalogOut
Explicit instantiation of derivable class NetworkAnalogOutT to create the network analog out instrume...
NetworkTimeTaggerT< typename NetworkDataStreamInstrument::ThisServiceType, DynExpProto::NetworkTimeTagger::NetworkTimeTagger > NetworkTimeTagger
Explicit instantiation of derivable class NetworkTimeTaggerT to create the network time tagger module...
NetworkAnalogInT< typename NetworkDataStreamInstrument::ThisServiceType, DynExpProto::NetworkAnalogIn::NetworkAnalogIn > NetworkAnalogIn
Explicit instantiation of derivable class NetworkAnalogInT to create the network analog in module.
NetworkDigitalInT< typename NetworkDataStreamInstrument::ThisServiceType, DynExpProto::NetworkDigitalIn::NetworkDigitalIn > NetworkDigitalIn
Explicit instantiation of derivable class NetworkDigitalInT to create the network digital in module.
NetworkDigitalOutT< typename NetworkDataStreamInstrument::ThisServiceType, DynExpProto::NetworkDigitalOut::NetworkDigitalOut > NetworkDigitalOut
Explicit instantiation of derivable class NetworkDigitalOutT to create the network digital out module...
NetworkDataStreamInstrumentT< DynExpProto::NetworkDataStreamInstrument::NetworkDataStreamInstrument > NetworkDataStreamInstrument
Explicit instantiation of derivable class NetworkDataStreamInstrumentT to create the network data str...
NetworkAnalogOutT< typename NetworkDataStreamInstrument::ThisServiceType, DynExpProto::NetworkAnalogOut::NetworkAnalogOut > NetworkAnalogOut
Explicit instantiation of derivable class NetworkAnalogOutT to create the network analog out module.
constexpr auto DefaultLocale
Default locale string.
constexpr auto DynExpName
DynExp's name string
constexpr auto DynExpDescription
DynExp's description string
constexpr auto DynExpVersion
DynExp's version string
const QLocale & GetDefaultQtLocale()
Returns the default locale properties to be assigned to Qt widgets.
Definition: QtUtil.cpp:12
EventLogger & EventLog()
This function holds a static EventLogger instance and returns a reference to it. DynExp uses only one...
Definition: Util.cpp:509
Accumulates include statements to provide a precompiled header.
Default number separators used within DynExp.