DynExp
Highly flexible laboratory automation for dynamically changing experiments.
DynExp::DynExpCore Class Referencefinal

DynExp's core class acts as the interface between the user interface and DynExp's internal data like all DynExp::Object instances and their threads. There should only be one instance of this class. It owns all DynExp resources through the respective ResourceManagerBase instances. Logical const-ness: Non-const functions (like functions to run/stop/reset/save/... the project) cannot be called from DynExp::Object instances possessing a const handle to the DynExpCore instance. Instead, these functions should be called through the user interface (from the DynExpManager instance). More...

+ Inheritance diagram for DynExp::DynExpCore:

Public Types

using ParamsTypeSyncPtrType = Util::SynchronizedPointer< ProjectParams >
 Alias for the return type of DynExpCore::GetParams(). Parameters wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way. More...
 
using ParamsConstTypeSyncPtrType = Util::SynchronizedPointer< const ProjectParams >
 Alias for the return type of DynExpCore::GetParams() const. Parameters wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way. More...
 

Public Member Functions

 DynExpCore (HardwareAdapterLibraryVectorType HardwareAdapterLib, InstrumentLibraryVectorType InstrumentLib, ModuleLibraryVectorType ModuleLib, std::string ProjectFileToOpen="")
 Constructs a DynExpCore instance. More...
 
 ~DynExpCore ()
 
void Shutdown ()
 Terminates DynExpCore::WorkerThread and waits until the thread has ended. More...
 
void Reset (bool Force=false)
 Resets the currently loaded project removing all resources from the resource managers. After a call to this function, a new empty project is available. More...
 
void SaveProject (std::string_view Filename, const QMainWindow &MainWindow, const QDialog &CircuitDiagramDlg, QSplitter &HSplitter, QSplitter &VSplitter)
 Saves the current DynExp project to an XML project file. More...
 
void OpenProject (std::string_view Filename)
 Loads a DynExp project from an XML project file. More...
 
void EditProjectSettings (QWidget *const DialogParent)
 Opens a settings dialog (ParamsConfigDialog) to let the user configure the parameter values of the current project settings stored in Params. More...
 
auto ConnectHardwareAdapters (CommonResourceManagerBase::FunctionToCallWhenObjectStartedType FunctionToCallWhenHardwareAdapterConnecting=nullptr)
 Connects all hardware adapters contained in HardwareAdapterMgr asynchronously calling ResourceManagerBase::Startup() More...
 
bool AllHardwareAdaptersConnected () const
 Checks whether all hardware adapters contained in HardwareAdapterMgr have been connected successfully. More...
 
bool AllInstrumentsInitialized () const
 Checks whether all instruments contained in InstrumentMgr have been initialized successfully. More...
 
void RunInstruments (CommonResourceManagerBase::FunctionToCallWhenObjectStartedType FunctionToCallWhenInstrumentStarted=nullptr)
 Runs all instruments contained in InstrumentMgr with RunnableObjectParams::StartupType::OnCreation startup setting. More...
 
void RunModules (CommonResourceManagerBase::FunctionToCallWhenObjectStartedType FunctionToCallWhenModuleStarted=nullptr)
 Runs all modules contained in ModuleMgr with RunnableObjectParams::StartupType::OnCreation startup setting. More...
 
void ShutdownProject ()
 Terminates all running instruments and modules. More...
 
void ResetFailedItems (QWidget &ParentWindow)
 Calls Object::Reset() and Object::ClearWarning() on all owned DynExp::Object instances which are in an error state. Considers dependencies in between these objects and stops and restarts related objects if required for resetting failed objects and if the user confirms. More...
 
void RestoreWindowStatesFromParams (QMainWindow &MainWindow, QDialog &CircuitDiagramDlg, QSplitter &HSplitter, QSplitter &VSplitter, bool OnlyMainWindow=false)
 Sets module and main windows' positions, sizes and styles according to parameters stored in the current project's configuration Params. More...
 
auto & GetHardwareAdapterLib () const noexcept
 Getter for the hardware adapter library. More...
 
auto & GetInstrumentLib () const noexcept
 Getter for the instrument library. More...
 
auto & GetModuleLib () const noexcept
 Getter for the module library. More...
 
auto & GetHardwareAdapterManager () noexcept
 Getter for the hardware adapter manager. More...
 
auto & GetInstrumentManager () noexcept
 Getter for the instrument manager. More...
 
auto & GetModuleManager () noexcept
 Getter for the module manager. More...
 
auto & GetHardwareAdapterManager () const noexcept
 Getter for the hardware adapter manager. More...
 
auto & GetInstrumentManager () const noexcept
 Getter for the instrument manager. More...
 
auto & GetModuleManager () const noexcept
 Getter for the module manager. More...
 
ItemIDType MakeItem (const LibraryEntry< HardwareAdapterPtrType > &LibEntry, ParamsBasePtrType &&Params)
 Creates a DynExp::HardwareAdapterBase instance from a LibraryEntry. More...
 
ItemIDType MakeItem (const LibraryEntry< InstrumentPtrType > &LibEntry, ParamsBasePtrType &&Params)
 Creates a DynExp::InstrumentBase instance from a LibraryEntry. More...
 
ItemIDType MakeItem (const LibraryEntry< ModulePtrType > &LibEntry, ParamsBasePtrType &&Params)
 Creates a DynExp::ModuleBase instance from a LibraryEntry. More...
 
bool HasLoadedProjectFromCommandlineParams () noexcept
 Indicates whether a DynExp project has been loaded from a path specified as a command line argument when starting DynExp. After the first call to this method, LoadedProjectFromCommandlineParams will always be false. More...
 
void MoveQWorkerToWorkerThread (Util::QWorker &Worker, ItemIDType ID) const
 Moves a Util::QWorker instance to WorkerThread to run its Qt event queue there. This method is thread-safe since it is only called by the main thread after it constructed a DynExp::Object instance. More...
 
std::string GetDataSaveDirectory (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
 Recalls a path where modules might save recorded data to. Used by Util::PromptSaveFilePathModule() to recall the directory the user has chosen last for saving a file. This directory is the same across all modules. More...
 
void SetDataSaveDirectory (const std::filesystem::path &Directory, const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault)
 Sets a path where modules might save recorded data to. Used by Util::PromptSaveFilePathModule() to store the directory the user has chosen last for saving a file. This directory is the same across all modules. More...
 
Thread-safe public functions

Methods can be called from any thread.

auto GetProjectFilename (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
 Locks Params and returns the current DynExp project's filename. More...
 
auto GetLastDataSaveDirectory (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
 Locks Params and returns the path to a directory where modules can save data. More...
 
bool IsProjectOpened (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const noexcept
 Locks Params and determines whether a project has been openend from a project file. More...
 
std::filesystem::path ToAbsolutePath (const std::filesystem::path &Path) const
 Transforms the path Path into an absolute path relative to ProjectParams::ProjectFilename. More...
 
ParamsConstTypeSyncPtrType GetParams (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
 Locks the mutex of the parameter class instance Params assigned to the current project and returns a pointer to the locked Params. More...
 
const auto GetOwnerThreadID () const noexcept
 Getter for the thread id of the thread which constructed (and owns) this DynExpCore instance. More...
 
- Public Member Functions inherited from Util::INonCopyable
 INonCopyable (const INonCopyable &)=delete
 
INonCopyableoperator= (const INonCopyable &)=delete
 

Static Public Attributes

static constexpr std::chrono::milliseconds GetParamsTimeoutDefault = std::chrono::milliseconds(100)
 Default timeout used by DynExpCore::GetParams() to lock the mutex of the project parameter instance. More...
 

Private Member Functions

bool OpenProjectSafe (const std::string &Filename) noexcept
 Calls OpenProject() and performs error handling for that function. More...
 
template<typename LibEntryT , typename ParamsT , typename ManagerT >
ItemIDType MakeItem (const LibraryEntry< LibEntryT > &LibEntry, ParamsT &&Params, ManagerT &ResourceManager, const std::string ItemTypeName)
 Creates a DynExp::Object instance from a LibraryEntry. More...
 
ParamsTypeSyncPtrType GetParams (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault)
 Locks the mutex of the parameter class instance Params assigned to the current project and returns a pointer to the locked Params. More...
 
void UpdateParamsFromWindowStates (const QMainWindow &MainWindow, const QDialog &CircuitDiagramDlg, QSplitter &HSplitter, QSplitter &VSplitter)
 Retrieves the module and main windows' positions, sizes and styles from the windows and updates the parameters stored in the current project's configuration Params accordingly. More...
 

Private Attributes

const HardwareAdapterLibraryVectorType HardwareAdapterLib
 Hardware adapter library vector containing information about all hardware adapters DynExp knows. More...
 
const InstrumentLibraryVectorType InstrumentLib
 Instrument library vector containing information about all instruments DynExp knows. More...
 
const ModuleLibraryVectorType ModuleLib
 Module library vector containing information about all modules DynExp knows. More...
 
bool LoadedProjectFromCommandlineParams
 This flag will be set to true if DynExpCore has been initialized with a path to a project file to load passed as a command line option. More...
 
std::unique_ptr< ProjectParamsParams
 Project parameters (configuration) of the current DynExp project. Must never be nullptr. More...
 
const std::thread::id OwnerThreadID
 The ID is set by DynExpCore::DynExpCore() to the id of the thread which constructed the DynExpCore instance. This thread owns the instance. Ownership cannot be transferred to another thread. The owning thread must also be the user interface thread. More...
 
QThread WorkerThread
 One worker thread runs the Qt event queues for all objects derived from Util::QWorker (e.g. hardware adapters derived from QSerialCommunicationHardwareAdapter). The derived Util::QWorker instances just insert tasks into the WorkerThread's event queue. Those tasks get executed asynchronously by Qt. This is required since QObject instances (like QSerialPort) cannot be shared between different (instrument) threads. Instead, QObject instances have to belong to one thread only (unfortunately). More...
 
Preserve declaration order

The DynExp::Object managers must be declared in this order to ensure that all Object instances making use of other Object instances are destroyed first upon the destruction of the DynExpCore instance.

HardwareAdapterManager HardwareAdapterMgr
 Hardware adapter manager owning all instantiated hardware adapters. More...
 
InstrumentManager InstrumentMgr
 Instrument manager owning all instantiated instruments. More...
 
ModuleManager ModuleMgr
 Module manager owning all instantiated modules. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Util::INonCopyable
constexpr INonCopyable ()=default
 
 ~INonCopyable ()=default
 

Detailed Description

DynExp's core class acts as the interface between the user interface and DynExp's internal data like all DynExp::Object instances and their threads. There should only be one instance of this class. It owns all DynExp resources through the respective ResourceManagerBase instances. Logical const-ness: Non-const functions (like functions to run/stop/reset/save/... the project) cannot be called from DynExp::Object instances possessing a const handle to the DynExpCore instance. Instead, these functions should be called through the user interface (from the DynExpManager instance).

Warning
Ownership of the DynExpCore instance must not be transferred to another thread than the one creating it.

Definition at line 126 of file DynExpCore.h.

Member Typedef Documentation

◆ ParamsConstTypeSyncPtrType

Alias for the return type of DynExpCore::GetParams() const. Parameters wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way.

Definition at line 139 of file DynExpCore.h.

◆ ParamsTypeSyncPtrType

Alias for the return type of DynExpCore::GetParams(). Parameters wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way.

Definition at line 133 of file DynExpCore.h.

Constructor & Destructor Documentation

◆ DynExpCore()

DynExp::DynExpCore::DynExpCore ( HardwareAdapterLibraryVectorType  HardwareAdapterLib,
InstrumentLibraryVectorType  InstrumentLib,
ModuleLibraryVectorType  ModuleLib,
std::string  ProjectFileToOpen = "" 
)

Constructs a DynExpCore instance.

Parameters
HardwareAdapterLibHardware adapters available to DynExp (result of LibraryBase::ToVector()).
InstrumentLibInstruments available to DynExp (result of LibraryBase::ToVector()).
ModuleLibModules available to DynExp (result of LibraryBase::ToVector()).
ProjectFileToOpenPath to a DynExp project XML file to load and to start

Definition at line 23 of file DynExpCore.cpp.

◆ ~DynExpCore()

DynExp::DynExpCore::~DynExpCore ( )

Definition at line 45 of file DynExpCore.cpp.

Member Function Documentation

◆ AllHardwareAdaptersConnected()

bool DynExp::DynExpCore::AllHardwareAdaptersConnected ( ) const

Checks whether all hardware adapters contained in HardwareAdapterMgr have been connected successfully.

Returns
Returns true if this is the case, false otherwise.

Definition at line 164 of file DynExpCore.cpp.

◆ AllInstrumentsInitialized()

bool DynExp::DynExpCore::AllInstrumentsInitialized ( ) const

Checks whether all instruments contained in InstrumentMgr have been initialized successfully.

Returns
Returns true if this is the case, false otherwise.

Definition at line 169 of file DynExpCore.cpp.

◆ ConnectHardwareAdapters()

auto DynExp::DynExpCore::ConnectHardwareAdapters ( CommonResourceManagerBase::FunctionToCallWhenObjectStartedType  FunctionToCallWhenHardwareAdapterConnecting = nullptr)
inline

Connects all hardware adapters contained in HardwareAdapterMgr asynchronously calling ResourceManagerBase::Startup()

Parameters
FunctionToCallWhenHardwareAdapterConnectingCallback function. Refer to FunctionToCallWhenObjectStartedType.
Returns
Returns a std::future instance. Refer to the documentation of std::async().

Definition at line 204 of file DynExpCore.h.

◆ EditProjectSettings()

void DynExp::DynExpCore::EditProjectSettings ( QWidget *const  DialogParent)

Opens a settings dialog (ParamsConfigDialog) to let the user configure the parameter values of the current project settings stored in Params.

Parameters
DialogParentQWidget acting as a parent of the modal settings dialog

Definition at line 156 of file DynExpCore.cpp.

◆ GetDataSaveDirectory()

std::string DynExp::DynExpCore::GetDataSaveDirectory ( const std::chrono::milliseconds  Timeout = GetParamsTimeoutDefault) const

Recalls a path where modules might save recorded data to. Used by Util::PromptSaveFilePathModule() to recall the directory the user has chosen last for saving a file. This directory is the same across all modules.

Returns
Path to show by default in the modules' file open/save dialogs.
Parameters
TimeoutTime to wait for locking the project parameters Params.

Definition at line 298 of file DynExpCore.cpp.

◆ GetHardwareAdapterLib()

auto& DynExp::DynExpCore::GetHardwareAdapterLib ( ) const
inlinenoexcept

Getter for the hardware adapter library.

Returns
Returns HardwareAdapterLib.

Definition at line 263 of file DynExpCore.h.

◆ GetHardwareAdapterManager() [1/2]

auto& DynExp::DynExpCore::GetHardwareAdapterManager ( ) const
inlinenoexcept

Getter for the hardware adapter manager.

Returns
Returns HardwareAdapterMgr.

Definition at line 295 of file DynExpCore.h.

◆ GetHardwareAdapterManager() [2/2]

auto& DynExp::DynExpCore::GetHardwareAdapterManager ( )
inlinenoexcept

Getter for the hardware adapter manager.

Returns
Returns HardwareAdapterMgr.

Definition at line 281 of file DynExpCore.h.

◆ GetInstrumentLib()

auto& DynExp::DynExpCore::GetInstrumentLib ( ) const
inlinenoexcept

Getter for the instrument library.

Returns
Returns InstrumentLib.

Definition at line 269 of file DynExpCore.h.

◆ GetInstrumentManager() [1/2]

auto& DynExp::DynExpCore::GetInstrumentManager ( ) const
inlinenoexcept

Getter for the instrument manager.

Returns
Returns InstrumentMgr.

Definition at line 296 of file DynExpCore.h.

◆ GetInstrumentManager() [2/2]

auto& DynExp::DynExpCore::GetInstrumentManager ( )
inlinenoexcept

Getter for the instrument manager.

Returns
Returns InstrumentMgr.

Definition at line 287 of file DynExpCore.h.

◆ GetLastDataSaveDirectory()

auto DynExp::DynExpCore::GetLastDataSaveDirectory ( const std::chrono::milliseconds  Timeout = GetParamsTimeoutDefault) const
inline

Locks Params and returns the path to a directory where modules can save data.

Parameters
TimeoutTime to wait for locking the mutex of Params.
Returns
Returns ProjectParams::LastDataSaveDirectory of Params.

Definition at line 347 of file DynExpCore.h.

◆ GetModuleLib()

auto& DynExp::DynExpCore::GetModuleLib ( ) const
inlinenoexcept

Getter for the module library.

Returns
Returns ModuleLib.

Definition at line 275 of file DynExpCore.h.

◆ GetModuleManager() [1/2]

auto& DynExp::DynExpCore::GetModuleManager ( ) const
inlinenoexcept

Getter for the module manager.

Returns
Returns ModuleMgr.

Definition at line 297 of file DynExpCore.h.

◆ GetModuleManager() [2/2]

auto& DynExp::DynExpCore::GetModuleManager ( )
inlinenoexcept

Getter for the module manager.

Returns
Returns ModuleMgr.

Definition at line 293 of file DynExpCore.h.

◆ GetOwnerThreadID()

const auto DynExp::DynExpCore::GetOwnerThreadID ( ) const
inlinenoexcept

Getter for the thread id of the thread which constructed (and owns) this DynExpCore instance.

Returns
Returns OwnerThreadID.

Definition at line 376 of file DynExpCore.h.

◆ GetParams() [1/2]

DynExpCore::ParamsTypeSyncPtrType DynExp::DynExpCore::GetParams ( const std::chrono::milliseconds  Timeout = GetParamsTimeoutDefault)
private

Locks the mutex of the parameter class instance Params assigned to the current project and returns a pointer to the locked Params.

Parameters
TimeoutTime to wait for locking the mutex of Params.
Returns
Returns a pointer to ProjectParams (non-const) to allow access to all of its members.

Definition at line 356 of file DynExpCore.cpp.

◆ GetParams() [2/2]

DynExpCore::ParamsConstTypeSyncPtrType DynExp::DynExpCore::GetParams ( const std::chrono::milliseconds  Timeout = GetParamsTimeoutDefault) const

Locks the mutex of the parameter class instance Params assigned to the current project and returns a pointer to the locked Params.

Parameters
TimeoutTime to wait for locking the mutex of Params.
Returns
Returns a pointer to const ProjectParams, since only this class itself is allowed to modify Params.

Definition at line 285 of file DynExpCore.cpp.

◆ GetProjectFilename()

auto DynExp::DynExpCore::GetProjectFilename ( const std::chrono::milliseconds  Timeout = GetParamsTimeoutDefault) const
inline

Locks Params and returns the current DynExp project's filename.

Parameters
TimeoutTime to wait for locking the mutex of Params.
Returns
Returns ProjectParams::ProjectFilename of Params.

Definition at line 340 of file DynExpCore.h.

◆ HasLoadedProjectFromCommandlineParams()

bool DynExp::DynExpCore::HasLoadedProjectFromCommandlineParams ( )
noexcept

Indicates whether a DynExp project has been loaded from a path specified as a command line argument when starting DynExp. After the first call to this method, LoadedProjectFromCommandlineParams will always be false.

Returns
Returns LoadedProjectFromCommandlineParams.

Definition at line 271 of file DynExpCore.cpp.

◆ IsProjectOpened()

bool DynExp::DynExpCore::IsProjectOpened ( const std::chrono::milliseconds  Timeout = GetParamsTimeoutDefault) const
inlinenoexcept

Locks Params and determines whether a project has been openend from a project file.

Parameters
TimeoutTime to wait for locking the mutex of Params.
Returns
Returns true when ProjectParams::ProjectFilename of Params is not empty, false otherwise.

Definition at line 354 of file DynExpCore.h.

◆ MakeItem() [1/4]

ItemIDType DynExp::DynExpCore::MakeItem ( const LibraryEntry< HardwareAdapterPtrType > &  LibEntry,
ParamsBasePtrType &&  Params 
)

Creates a DynExp::HardwareAdapterBase instance from a LibraryEntry.

Parameters
LibEntryEntry of HardwareAdapterLib to instantiate
ParamsReference to the Object's parameters to take ownership of
Returns
Returns the Object ID of the newly generated Object instance.

Definition at line 256 of file DynExpCore.cpp.

◆ MakeItem() [2/4]

ItemIDType DynExp::DynExpCore::MakeItem ( const LibraryEntry< InstrumentPtrType > &  LibEntry,
ParamsBasePtrType &&  Params 
)

Creates a DynExp::InstrumentBase instance from a LibraryEntry.

Parameters
LibEntryEntry of InstrumentLib to instantiate
ParamsReference to the Object's parameters to take ownership of
Returns
Returns the Object ID of the newly generated Object instance.

Definition at line 261 of file DynExpCore.cpp.

◆ MakeItem() [3/4]

template<typename LibEntryT , typename ParamsT , typename ManagerT >
ItemIDType DynExp::DynExpCore::MakeItem ( const LibraryEntry< LibEntryT > &  LibEntry,
ParamsT &&  Params,
ManagerT &  ResourceManager,
const std::string  ItemTypeName 
)
private

Creates a DynExp::Object instance from a LibraryEntry.

Template Parameters
LibEntryTPointer to the base type of a certain DynExp resource (e.g. DynExp::ModulePtrType)
ParamsTType of the parameter base class related to DynExp::Object instances of type LibEntryT
ManagerTType of the resource manager managing instances of type LibEntryT.
Parameters
LibEntryLibrary entry to instantiate
ParamsReference to the Object's parameters to take ownership of
ResourceManagerResource manager to insert the newly generated Object instance into
ItemTypeNameHuman-readable type name of the types managed by ResourceManager to be displayed in log messages.
Returns
Returns the Object ID of the newly generated Object instance.

Definition at line 488 of file DynExpCore.h.

◆ MakeItem() [4/4]

ItemIDType DynExp::DynExpCore::MakeItem ( const LibraryEntry< ModulePtrType > &  LibEntry,
ParamsBasePtrType &&  Params 
)

Creates a DynExp::ModuleBase instance from a LibraryEntry.

Parameters
LibEntryEntry of ModuleLib to instantiate
ParamsReference to the Object's parameters to take ownership of
Returns
Returns the Object ID of the newly generated Object instance.

Definition at line 266 of file DynExpCore.cpp.

◆ MoveQWorkerToWorkerThread()

void DynExp::DynExpCore::MoveQWorkerToWorkerThread ( Util::QWorker Worker,
ItemIDType  ID 
) const

Moves a Util::QWorker instance to WorkerThread to run its Qt event queue there. This method is thread-safe since it is only called by the main thread after it constructed a DynExp::Object instance.

Parameters
WorkerUtil::QWorker instance to move to DynExp's worker thread WorkerThread. Refer to Util::QWorker and to WorkerThread.
IDObject ID of the DynExp::Object owning Worker.

Definition at line 290 of file DynExpCore.cpp.

◆ OpenProject()

void DynExp::DynExpCore::OpenProject ( std::string_view  Filename)

Loads a DynExp project from an XML project file.

Parameters
FilenamePath to a DynExp project XML file to load
Exceptions
Util::InvalidDataExceptionis thrown if the data contained in the file Filename refers to could not be parsed as XML.

Definition at line 114 of file DynExpCore.cpp.

◆ OpenProjectSafe()

bool DynExp::DynExpCore::OpenProjectSafe ( const std::string &  Filename)
privatenoexcept

Calls OpenProject() and performs error handling for that function.

Parameters
FilenamePath of the project file to open.
Returns
Returns true if a project has been opened successfully, false otherwise.

Definition at line 313 of file DynExpCore.cpp.

◆ Reset()

void DynExp::DynExpCore::Reset ( bool  Force = false)

Resets the currently loaded project removing all resources from the resource managers. After a call to this function, a new empty project is available.

Parameters
ForceIf false, ResourceManagerBase::PrepareReset() is called on each owned resource manager, before calls to ResourceManagerBase::Reset() follow. If true, only the latter method is called.

Definition at line 58 of file DynExpCore.cpp.

◆ ResetFailedItems()

void DynExp::DynExpCore::ResetFailedItems ( QWidget &  ParentWindow)

Calls Object::Reset() and Object::ClearWarning() on all owned DynExp::Object instances which are in an error state. Considers dependencies in between these objects and stops and restarts related objects if required for resetting failed objects and if the user confirms.

Parameters
ParentWindowQWidget acting as a parent of modal dialog boxes, which are potentially displayed.

Definition at line 190 of file DynExpCore.cpp.

◆ RestoreWindowStatesFromParams()

void DynExp::DynExpCore::RestoreWindowStatesFromParams ( QMainWindow &  MainWindow,
QDialog &  CircuitDiagramDlg,
QSplitter &  HSplitter,
QSplitter &  VSplitter,
bool  OnlyMainWindow = false 
)

Sets module and main windows' positions, sizes and styles according to parameters stored in the current project's configuration Params.

Parameters
MainWindowDynExp's main window (DynExpManager instance) whose window state to save
CircuitDiagramDlgDynExp's circuit diagram window (CircuitDiagram instance) whose window state to save
HSplitterHorizontal main splitter widget in the main window
VSplitterVertical main splitter widget in the main window
OnlyMainWindowIf true, only applies window states from the project settings to the main window. If false, also applies saved window states to module windows.

Definition at line 231 of file DynExpCore.cpp.

◆ RunInstruments()

void DynExp::DynExpCore::RunInstruments ( CommonResourceManagerBase::FunctionToCallWhenObjectStartedType  FunctionToCallWhenInstrumentStarted = nullptr)

Runs all instruments contained in InstrumentMgr with RunnableObjectParams::StartupType::OnCreation startup setting.

Parameters
FunctionToCallWhenInstrumentStartedCallback function. Refer to FunctionToCallWhenObjectStartedType.

Definition at line 174 of file DynExpCore.cpp.

◆ RunModules()

void DynExp::DynExpCore::RunModules ( CommonResourceManagerBase::FunctionToCallWhenObjectStartedType  FunctionToCallWhenModuleStarted = nullptr)

Runs all modules contained in ModuleMgr with RunnableObjectParams::StartupType::OnCreation startup setting.

Parameters
FunctionToCallWhenModuleStartedCallback function. Refer to FunctionToCallWhenObjectStartedType.

Definition at line 179 of file DynExpCore.cpp.

◆ SaveProject()

void DynExp::DynExpCore::SaveProject ( std::string_view  Filename,
const QMainWindow &  MainWindow,
const QDialog &  CircuitDiagramDlg,
QSplitter &  HSplitter,
QSplitter &  VSplitter 
)

Saves the current DynExp project to an XML project file.

Parameters
FilenamePath where to save the DynExp project XML file
MainWindowDynExp's main window (DynExpManager instance) whose window state to save
CircuitDiagramDlgDynExp's circuit diagram window (CircuitDiagram instance) whose window state to save
HSplitterHorizontal main splitter widget in the main window
VSplitterVertical main splitter widget in the main window

Definition at line 81 of file DynExpCore.cpp.

◆ SetDataSaveDirectory()

void DynExp::DynExpCore::SetDataSaveDirectory ( const std::filesystem::path &  Directory,
const std::chrono::milliseconds  Timeout = GetParamsTimeoutDefault 
)

Sets a path where modules might save recorded data to. Used by Util::PromptSaveFilePathModule() to store the directory the user has chosen last for saving a file. This directory is the same across all modules.

Parameters
DirectoryPath to show by default in the modules' file open/save dialogs.
TimeoutTime to wait for locking the project parameters Params.

Definition at line 308 of file DynExpCore.cpp.

◆ Shutdown()

void DynExp::DynExpCore::Shutdown ( )

Terminates DynExpCore::WorkerThread and waits until the thread has ended.

Exceptions
Util::ThreadDidNotRespondExceptionis thrown if WorkerThread does not terminate in due time.

Definition at line 50 of file DynExpCore.cpp.

◆ ShutdownProject()

void DynExp::DynExpCore::ShutdownProject ( )

Terminates all running instruments and modules.

Definition at line 184 of file DynExpCore.cpp.

◆ ToAbsolutePath()

std::filesystem::path DynExp::DynExpCore::ToAbsolutePath ( const std::filesystem::path &  Path) const

Transforms the path Path into an absolute path relative to ProjectParams::ProjectFilename.

Parameters
PathRelative path to be transformed
Returns
Transformed path or Path itself if it is either empty or already absolute.

Definition at line 279 of file DynExpCore.cpp.

◆ UpdateParamsFromWindowStates()

void DynExp::DynExpCore::UpdateParamsFromWindowStates ( const QMainWindow &  MainWindow,
const QDialog &  CircuitDiagramDlg,
QSplitter &  HSplitter,
QSplitter &  VSplitter 
)
private

Retrieves the module and main windows' positions, sizes and styles from the windows and updates the parameters stored in the current project's configuration Params accordingly.

Parameters
MainWindowDynExp's main window (DynExpManager instance) whose window state to save
CircuitDiagramDlgDynExp's circuit diagram window (CircuitDiagram instance) whose window state to save
HSplitterHorizontal main splitter widget in the main window
VSplitterVertical main splitter widget in the main window

Definition at line 361 of file DynExpCore.cpp.

Member Data Documentation

◆ GetParamsTimeoutDefault

constexpr std::chrono::milliseconds DynExp::DynExpCore::GetParamsTimeoutDefault = std::chrono::milliseconds(100)
staticconstexpr

Default timeout used by DynExpCore::GetParams() to lock the mutex of the project parameter instance.

Definition at line 145 of file DynExpCore.h.

◆ HardwareAdapterLib

const HardwareAdapterLibraryVectorType DynExp::DynExpCore::HardwareAdapterLib
private

Hardware adapter library vector containing information about all hardware adapters DynExp knows.

Definition at line 441 of file DynExpCore.h.

◆ HardwareAdapterMgr

HardwareAdapterManager DynExp::DynExpCore::HardwareAdapterMgr
private

Hardware adapter manager owning all instantiated hardware adapters.

Definition at line 451 of file DynExpCore.h.

◆ InstrumentLib

const InstrumentLibraryVectorType DynExp::DynExpCore::InstrumentLib
private

Instrument library vector containing information about all instruments DynExp knows.

Definition at line 442 of file DynExpCore.h.

◆ InstrumentMgr

InstrumentManager DynExp::DynExpCore::InstrumentMgr
private

Instrument manager owning all instantiated instruments.

Definition at line 452 of file DynExpCore.h.

◆ LoadedProjectFromCommandlineParams

bool DynExp::DynExpCore::LoadedProjectFromCommandlineParams
private

This flag will be set to true if DynExpCore has been initialized with a path to a project file to load passed as a command line option.

Definition at line 460 of file DynExpCore.h.

◆ ModuleLib

const ModuleLibraryVectorType DynExp::DynExpCore::ModuleLib
private

Module library vector containing information about all modules DynExp knows.

Definition at line 443 of file DynExpCore.h.

◆ ModuleMgr

ModuleManager DynExp::DynExpCore::ModuleMgr
private

Module manager owning all instantiated modules.

Definition at line 453 of file DynExpCore.h.

◆ OwnerThreadID

const std::thread::id DynExp::DynExpCore::OwnerThreadID
private

The ID is set by DynExpCore::DynExpCore() to the id of the thread which constructed the DynExpCore instance. This thread owns the instance. Ownership cannot be transferred to another thread. The owning thread must also be the user interface thread.

Definition at line 472 of file DynExpCore.h.

◆ Params

std::unique_ptr<ProjectParams> DynExp::DynExpCore::Params
private

Project parameters (configuration) of the current DynExp project. Must never be nullptr.

Definition at line 465 of file DynExpCore.h.

◆ WorkerThread

QThread DynExp::DynExpCore::WorkerThread
mutableprivate

One worker thread runs the Qt event queues for all objects derived from Util::QWorker (e.g. hardware adapters derived from QSerialCommunicationHardwareAdapter). The derived Util::QWorker instances just insert tasks into the WorkerThread's event queue. Those tasks get executed asynchronously by Qt. This is required since QObject instances (like QSerialPort) cannot be shared between different (instrument) threads. Instead, QObject instances have to belong to one thread only (unfortunately).

Definition at line 484 of file DynExpCore.h.


The documentation for this class was generated from the following files: