DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
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
67#ifdef USE_NIDAQ
72#endif // USE_NIDAQ
73#ifdef USE_PVCAM
74#include "Instruments/PVCam.h"
75#endif // USE_PVCAM
76#ifdef USE_QUTOOLSQUTAG
78#endif // USE_QUTOOLSQUTAG
79#ifdef USE_SMARACT
80#include "Instruments/SmarAct.h"
81#endif // USE_SMARACT
82#ifdef USE_SWABIANPULSESTREAMER
84#endif // USE_SWABIANPULSESTREAMER
85#ifdef USE_ZIMFLI
86#include "Instruments/ZI_MFLI.h"
87#endif // USE_ZIMFLI
88
89// Modules
91#include "Modules/EventSender.h"
107#include "Modules/Stage1D.h"
109#include "Modules/Trajectory1D.h"
110
111// Experiment modules
113#include "Modules/ODMR/ODMR.h"
114
123int main(int argc, char *argv[])
124{
128#ifdef USE_NIDAQ
130#endif // USE_NIDAQ
131#ifdef USE_PVCAM
133#endif // USE_PVCAM
134#ifdef USE_QUTOOLSQUTAG
136#endif // USE_QUTOOLSQUTAG
137#ifdef USE_SMARACT
139#endif // USE_SMARACT
140#ifdef USE_SWABIANPULSESTREAMER
142#endif // USE_SWABIANPULSESTREAMER
143#ifdef USE_ZIMFLI
145#endif // USE_ZIMFLI
146 > HardwareAdapterLib;
147
170#ifdef USE_NIDAQ
175#endif // USE_NIDAQ
176#ifdef USE_PVCAM
178#endif // USE_PVCAM
179#ifdef USE_QUTOOLSQUTAG
181#endif // USE_QUTOOLSQUTAG
182#ifdef USE_SMARACT
184#endif // USE_SMARACT
185#ifdef USE_SWABIANPULSESTREAMER
187#endif // USE_SWABIANPULSESTREAMER
188#ifdef USE_ZIMFLI
190#endif // USE_ZIMFLI
191 > InstrumentLib;
192
193 constexpr DynExp::ModuleLibrary<
214 //
215 // Experiments
218 > ModuleLib;
219
220 int ErrorReturnCode = Util::DynExpErrorCodes::GeneralError;
221 try
222 {
223 // Set up language and application settings.
224 std::locale::global(std::locale(std::locale(DynExp::DefaultLocale), new DynExp::DefaultLocaleSeparator));
225 QLocale::setDefault(Util::GetDefaultQtLocale());
226
227 QApplication App(argc, argv);
228 QApplication::setApplicationName(DynExp::DynExpName);
229 QApplication::setApplicationVersion(DynExp::DynExpVersion);
230
231 // Turn off GSL error handler.
232 gsl_set_error_handler_off();
233
234 // Initialize Python interpreter.
235 Util::PyGilReleasedInterpreter PyInterpreter;
236
237 // Parse command line options.
238 QCommandLineParser Parser;
239 Parser.setApplicationDescription(DynExp::DynExpDescription);
240 Parser.addHelpOption();
241 Parser.addVersionOption();
242 Parser.addPositionalArgument("file", "Project file (*.dynp) to open.");
243 Parser.process(App);
244
245 QString ProjectFile;
246 if (!Parser.positionalArguments().empty())
247 ProjectFile = Parser.positionalArguments()[0];
248
249 // Initialize DynExp.
250 auto DynExpCore = std::make_unique<DynExp::DynExpCore>(HardwareAdapterLib.ToVector(), InstrumentLib.ToVector(), ModuleLib.ToVector(),
251 ProjectFile.toStdString());
252 auto DynExpMgr = std::make_unique<DynExpManager>(*DynExpCore);
253 DynExpMgr->showMaximized();
254
255#ifdef DYNEXP_DEBUG
256 PyInterpreter.PrintDebugInfo();
257#endif // DYNEXP_DEBUG
258
259 // All exceptions need to be caught in Qt event handlers. Exceptions leaving slots is considered undefined behaviour.
260 // The exception does not propagate here! See https://doc.qt.io/qt-5/exceptionsafety.html
261 return App.exec();
262 }
263 catch (const Util::Exception& e)
264 {
265 Util::EventLog().Log(e);
266 ErrorReturnCode = e.ErrorCode;
267
268#ifdef DYNEXP_DEBUG
269 throw;
270#endif // DYNEXP_DEBUG
271 }
272 catch (const std::exception& e)
273 {
274 Util::EventLog().Log(e.what(), Util::ErrorType::Fatal, ErrorReturnCode);
275
276#ifdef DYNEXP_DEBUG
277 throw;
278#endif // DYNEXP_DEBUG
279 }
280 catch (...)
281 {
282 Util::EventLog().Log("Unknown Error", Util::ErrorType::Fatal, ErrorReturnCode);
283
284#ifdef DYNEXP_DEBUG
285 throw;
286#endif // DYNEXP_DEBUG
287 }
288
289 return ErrorReturnCode;
290}
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 an analog input port instrument without any related physical hardware.
Implementation of an analog output port instrument without any related physical hardware.
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.
Implementation of a digital input port instrument without any related physical hardware.
Implementation of a digital output port instrument without any related physical hardware.
Implements DynExp's main UI window called DynExpManager.
Implementation of a module to let the user manually issue inter-module events.
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 laser source.
Implementation of a module to perform photoluminescence excitation spectroscopy.
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 Newport stages with the Conex-CC controller.
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 laser 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....
Explicit instantiation of derivable class NetworkDataStreamInstrumentT to create the network data str...
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:317
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:107
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:123
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:517
Accumulates include statements to provide a precompiled header.
Default number separators used within DynExp.