DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
EventSender.h
Go to the documentation of this file.
1// This file is part of DynExp.
2
8#pragma once
9
10#include "stdafx.h"
11#include "DynExpCore.h"
12#include "../Instruments/InterModuleCommunicator.h"
13
14#include "CommonModuleEvents.h"
15
16#include <QWidget>
17
18namespace Ui
19{
20 class EventSender;
21}
22
23namespace DynExpModule
24{
25 class EventSender;
26
28 {
29 Q_OBJECT
30
31 public:
33 ~EventSenderWidget() = default;
34
35 bool AllowResize() const noexcept override final { return true; }
36
37 std::unique_ptr<Ui::EventSender> ui;
38
39 size_t EventID;
40
41 private slots:
42 void OnEventDoubleClicked(QListWidgetItem* Item);
43 };
44
63
65 {
66 public:
68 virtual ~EventSenderParams() = default;
69
70 virtual const char* GetParamClassTag() const noexcept override { return "EventSenderParams"; }
71
73 "InterModuleCommunicator", "Inter-module communicator", "Inter-module communicator to send inter-module events to", DynExpUI::Icons::Instrument };
74
75 private:
77 };
78
80 {
81 public:
84
86 virtual ~EventSenderConfigurator() = default;
87
88 private:
89 virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override final { return DynExp::MakeParams<EventSenderConfigurator>(ID, Core); }
90 };
91
93 {
94 public:
98
99 constexpr static auto Name() noexcept { return "Inter-Module Event Sender"; }
100 constexpr static auto Category() noexcept { return "General"; }
101
104 virtual ~EventSender() = default;
105
106 virtual std::string GetName() const override { return Name(); }
107 virtual std::string GetCategory() const override { return Category(); }
108
109 bool TreatModuleExceptionsAsWarnings() const override { return false; }
110
111 // Only run main loop in case of an event.
112 std::chrono::milliseconds GetMainLoopDelay() const override final { return decltype(ModuleBase::GetMainLoopDelay())::max(); }
113
114 private:
116
117 void ResetImpl(dispatch_tag<QModuleBase>) override final;
118
119 std::unique_ptr<DynExp::QModuleWidget> MakeUIWidget() override final;
120 void UpdateUIChild(const ModuleBase::ModuleDataGetterType& ModuleDataGetter) override final;
121
122 // Events, run in module thread
123 void OnInit(DynExp::ModuleInstance* Instance) const override final;
124 void OnExit(DynExp::ModuleInstance* Instance) const override final;
125
126 };
127}
Provides common events for inter-module communication. Also refer to DynExp::InterModuleEventBase.
Defines DynExp's core module as an interface between the UI and DynExp objects.
virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core) const override final
Override to make derived classes call DynExp::MakeParams with the correct configurator type derived f...
Definition EventSender.h:89
virtual ~EventSenderConfigurator()=default
DynExp::LinkedObjectWrapperContainer< DynExpInstr::InterModuleCommunicator > Communicator
Definition EventSender.h:51
virtual void ResetImpl(dispatch_tag< EventSenderData >)
Definition EventSender.h:59
virtual ~EventSenderData()=default
void ResetImpl(dispatch_tag< QModuleDataBase >) override final
Param< DynExp::ObjectLink< DynExpInstr::InterModuleCommunicator > > Communicator
Definition EventSender.h:72
EventSenderParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
Definition EventSender.h:67
virtual const char * GetParamClassTag() const noexcept override
This function is intended to be overridden once in each derived class returning the name of the respe...
Definition EventSender.h:70
void ConfigureParamsImpl(dispatch_tag< QModuleParamsBase >) override final
Definition EventSender.h:76
virtual ~EventSenderParams()=default
std::unique_ptr< Ui::EventSender > ui
Definition EventSender.h:37
bool AllowResize() const noexcept override final
Indicates the resizing behavior of the user interface window. Override to adjust.
Definition EventSender.h:35
void OnEventDoubleClicked(QListWidgetItem *Item)
Util::DynExpErrorCodes::DynExpErrorCodes ModuleMainLoop(DynExp::ModuleInstance &Instance) override final
Module main loop. The function is executed periodically by the module thread. Also refer to GetMainLo...
static constexpr auto Name() noexcept
Definition EventSender.h:99
void ResetImpl(dispatch_tag< QModuleBase >) override final
virtual ~EventSender()=default
virtual std::string GetCategory() const override
Returns the category of this Object type.
void OnExit(DynExp::ModuleInstance *Instance) const override final
This event is triggered right before the module thread terminates (not due to an exception,...
std::unique_ptr< DynExp::QModuleWidget > MakeUIWidget() override final
Used by InitUI() as a factory function for the module's user interface widget. Create the widget here...
void OnInit(DynExp::ModuleInstance *Instance) const override final
This event is triggered right before the module thread starts. Override it to lock instruments this m...
static constexpr auto Category() noexcept
EventSender(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
virtual std::string GetName() const override
Returns the name of this Object type.
std::chrono::milliseconds GetMainLoopDelay() const override final
Specifies in which time intervals the module's event queue runs to handle pending events.
bool TreatModuleExceptionsAsWarnings() const override
Determines whether this module should be terminated if an exception leaves the module's main loop or ...
void UpdateUIChild(const ModuleBase::ModuleDataGetterType &ModuleDataGetter) override final
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Definition DynExpCore.h:127
This class holds a pointer (LinkedObjectWrapperPointer) to a LinkedObjectWrapper. Intances of this cl...
Definition Object.h:3168
Util::CallableMemberWrapper< ModuleBase, ModuleDataTypeSyncPtrType(ModuleBase::*)(const std::chrono::milliseconds)> ModuleDataGetterType
Invoking an instance of this alias is supposed to call ModuleBase::GetModuleData() of the instance th...
Definition Module.h:624
ModuleBase(const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params)
Constructs a ModuleBase instance.
Definition Module.cpp:206
Refer to ParamsBase::dispatch_tag.
Definition Module.h:191
Defines data for a thread belonging to a ModuleBase instance. Refer to RunnableInstance.
Definition Module.h:840
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
const auto & GetCore() const noexcept
Returns a reference to DynExp's core.
Definition Object.h:1677
const ItemIDType ID
ID of the Object this parameter class instance belongs to.
Definition Object.h:1779
const DynExpCore & Core
Reference to DynExp's core.
Definition Object.h:1780
Tag for function dispatching mechanism within this class used when derived classes are not intended t...
Definition Object.h:349
Base class for modules with a Qt-based user interface. Derive from this class to implement modules wi...
Definition Module.h:1660
QModuleBase(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Constructs a QModuleBase instance.
Definition Module.cpp:591
Configurator class for QModuleBase.
Definition Module.h:1646
Data class for QModuleBase.
Definition Module.h:1536
Parameter class for QModuleBase.
Definition Module.h:1622
QModuleParamsBase(ItemIDType ID, const DynExpCore &Core)
Constructs the parameters for a QModuleBase instance.
Definition Module.h:1628
Window class for Qt-based user interfaces belonging to DynExp modules. User interface Qt window class...
Definition Module.h:1395
QModuleBase & Owner
Module owning this user interface window (reference, because it should never change nor be nullptr).
Definition Module.h:1478
QModuleWidget(QModuleBase &Owner, QWidget *Parent=nullptr)
Constructs a QModuleWidget instance.
Definition Module.cpp:451
DynExp's module namespace contains the implementation of DynExp modules which extend DynExp's core fu...
constexpr auto Instrument
DynExp's main namespace contains the implementation of DynExp including classes to manage resources (...
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
Definition Object.h:1807
size_t ItemIDType
ID type of objects/items managed by DynExp.
DynExpErrorCodes
DynExp's error codes
Definition Exception.h:22
Accumulates include statements to provide a precompiled header.