DynExp
Highly flexible laboratory automation for dynamically changing experiments.
OutputPortWriter.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 "../MetaInstruments/OutputPort.h"
13 
14 #include <QWidget>
15 #include "ui_OutputPortWriter.h"
16 
17 namespace DynExpModule
18 {
19  class OutputPortWriter;
20 
22  {
23  Q_OBJECT
24 
25  public:
28 
29  Ui::OutputPortWriter ui;
30  };
31 
33  {
34  public:
36  virtual ~OutputPortWriterData() = default;
37 
39 
45  double Value;
46 
47  private:
48  void ResetImpl(dispatch_tag<QModuleDataBase>) override final;
50 
51  void Init();
52  };
53 
55  {
56  public:
58  virtual ~OutputPortWriterParams() = default;
59 
60  virtual const char* GetParamClassTag() const noexcept override { return "OutputPortWriterParams"; }
61 
63  "OutputPort", "Output port", "Underlying output port to be controlled by this module", DynExpUI::Icons::Instrument };
64 
65  private:
67  };
68 
70  {
71  public:
74 
76  virtual ~OutputPortWriterConfigurator() = default;
77 
78  private:
79  virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override final { return DynExp::MakeParams<OutputPortWriterConfigurator>(ID, Core); }
80  };
81 
83  {
84  public:
88 
89  constexpr static auto Name() noexcept { return "Output Port Writer"; }
90  constexpr static auto Category() noexcept { return "I/O"; }
91 
93  : QModuleBase(OwnerThreadID, std::move(Params)) {}
94  virtual ~OutputPortWriter() = default;
95 
96  virtual std::string GetName() const override { return Name(); }
97  virtual std::string GetCategory() const override { return Category(); }
98 
99  std::chrono::milliseconds GetMainLoopDelay() const override final { return std::chrono::milliseconds(50); }
100 
101  private:
102  static constexpr auto DialControlValueDivider = 100;
103 
105 
106  void ResetImpl(dispatch_tag<QModuleBase>) override final;
107 
108  std::unique_ptr<DynExp::QModuleWidget> MakeUIWidget() override final;
109  void UpdateUIChild(const ModuleBase::ModuleDataGetterType& ModuleDataGetter) override final;
110 
111  // Events, run in module thread
112  void OnInit(DynExp::ModuleInstance* Instance) const override final;
113  void OnExit(DynExp::ModuleInstance* Instance) const override final;
114  void OnValueChanged(DynExp::ModuleInstance* Instance, int Value) const;
115  void OnStateButtonClicked(DynExp::ModuleInstance* Instance, bool Checked) const;
116  };
117 }
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...
void ResetImpl(dispatch_tag< QModuleDataBase >) override final
virtual void ResetImpl(dispatch_tag< OutputPortWriterData >)
DynExp::LinkedObjectWrapperContainer< DynExpInstr::OutputPort > OutputPort
virtual ~OutputPortWriterData()=default
void ConfigureParamsImpl(dispatch_tag< QModuleParamsBase >) override final
virtual ~OutputPortWriterParams()=default
OutputPortWriterParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
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...
Param< DynExp::ObjectLink< DynExpInstr::OutputPort > > OutputPort
OutputPortWriterWidget(OutputPortWriter &Owner, QModuleWidget *parent=nullptr)
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...
constexpr static auto Category() noexcept
virtual std::string GetCategory() const override
Returns the category of this Object type.
void OnStateButtonClicked(DynExp::ModuleInstance *Instance, bool Checked) const
void OnExit(DynExp::ModuleInstance *Instance) const override final
This event is triggered right before the module thread terminates (not due to an exception,...
static constexpr auto DialControlValueDivider
void OnValueChanged(DynExp::ModuleInstance *Instance, int Value) const
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...
virtual ~OutputPortWriter()=default
virtual std::string GetName() const override
Returns the name of this Object type.
constexpr static auto Name() noexcept
void UpdateUIChild(const ModuleBase::ModuleDataGetterType &ModuleDataGetter) override final
void ResetImpl(dispatch_tag< QModuleBase >) override final
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...
OutputPortWriter(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
std::chrono::milliseconds GetMainLoopDelay() const override final
Specifies in which time intervals the module's event queue runs to handle pending events.
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Definition: DynExpCore.h:127
Base class for modules. Modules implement programs on their own (e.g. measurement protocols or server...
Definition: Module.h:392
ModuleBase(const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params)
Constructs a ModuleBase instance.
Definition: Module.cpp:189
Configurator class for ModuleBase.
Definition: Module.h:374
Data structure to contain data which is synchronized in between different threads....
Definition: Module.h:171
Refer to ParamsBase::dispatch_tag.
Definition: Module.h:189
Defines data for a thread belonging to a ModuleBase instance. Refer to RunnableInstance.
Definition: Module.h:793
Parameter class for ModuleBase.
Definition: Module.h:337
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
const ItemIDType ID
ID of the Object this parameter class instance belongs to.
Definition: Object.h:1779
const auto & GetCore() const noexcept
Returns a reference to DynExp's core.
Definition: Object.h:1677
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:1344
QModuleBase(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Constructs a QModuleBase instance.
Definition: Module.cpp:557
Configurator class for QModuleBase.
Definition: Module.h:1330
Data class for QModuleBase.
Definition: Module.h:1220
Parameter class for QModuleBase.
Definition: Module.h:1306
QModuleParamsBase(ItemIDType ID, const DynExpCore &Core)
Constructs the parameters for a QModuleBase instance.
Definition: Module.h:1312
Window class for Qt-based user interfaces belonging to DynExp modules. User interface Qt window class...
Definition: Module.h:1079
QModuleBase & Owner
Module owning this user interface window (reference, because it should never change nor be nullptr).
Definition: Module.h:1162
QModuleWidget(QModuleBase &Owner, QWidget *Parent=nullptr)
Constructs a QModuleWidget instance.
Definition: Module.cpp:417
Wraps a member function of some object and stores its default arguments. Moving from CallableMemberWr...
Definition: Util.h:448
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.