DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
Stage.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 "Instrument.h"
12
13namespace DynExpInstr
14{
15 class PositionerStage;
16
61
66 {
67 public:
71 using PositionType = signed long long;
72
74 virtual ~PositionerStageData() = default;
75
76 auto GetCurrentPosition() const noexcept { return Position; }
77 auto GetVelocity() const noexcept { return Velocity; }
79 void SetVelocity(PositionType Velocity) noexcept { this->Velocity = Velocity; }
80
81 bool IsMoving() const noexcept { return IsMovingChild(); }
82 bool HasArrived() const noexcept { return HasArrivedChild(); }
83 bool HasFailed() const noexcept { return HasFailedChild(); }
84 bool IsReferenced() const noexcept { return IsReferencedChild(); }
85
86 private:
87 void ResetImpl(dispatch_tag<InstrumentDataBase>) override final;
88
93
98 virtual bool IsMovingChild() const noexcept = 0;
99 virtual bool HasArrivedChild() const noexcept = 0;
100 virtual bool HasFailedChild() const noexcept = 0;
101 virtual bool IsReferencedChild() const noexcept { return false; }
103
108
113 };
114
119 {
120 public:
126
127 virtual ~PositionerStageParams() = 0;
128
129 virtual const char* GetParamClassTag() const noexcept override { return "PositionerStageParams"; }
130
131 private:
134
135 DummyParam Dummy = { *this };
136 };
137
150
155 {
156 public:
173
182
183 constexpr static auto Name() noexcept { return "Positioner Stage"; }
184 constexpr static auto Category() noexcept { return "Positioners"; }
185
191
192 virtual ~PositionerStage() = 0;
193
194 virtual std::string GetName() const override { return Name(); }
195 virtual std::string GetCategory() const override { return Category(); }
196
197 virtual std::chrono::milliseconds GetTaskQueueDelay() const override { return std::chrono::milliseconds(100); }
198
204 virtual PositionerStageData::PositionType GetMaxPosition() const noexcept = 0;
205 virtual PositionerStageData::PositionType GetResolution() const noexcept = 0;
206
207 virtual PositionerStageData::PositionType GetMinVelocity() const noexcept = 0;
208 virtual PositionerStageData::PositionType GetMaxVelocity() const noexcept = 0;
209 virtual PositionerStageData::PositionType GetDefaultVelocity() const noexcept = 0;
210
217 virtual double GetStepNanoMeterRatio() const noexcept { return 1; }
218
224 virtual bool IsUsingSIUnits() const noexcept { return false; }
226
233
238 virtual void SetHome() const;
239
248 virtual void Reference(DirectionType Direction = DirectionType::Forward, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const;
249
257 virtual void Calibrate(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const;
258
265 virtual void SetVelocity(const PositionerStageData::PositionType Velocity) const = 0;
266
273 virtual void MoveToHome(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const;
274
282 virtual void MoveAbsolute(const PositionerStageData::PositionType Steps, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const = 0;
283
292 virtual void MoveRelative(const PositionerStageData::PositionType Steps, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const = 0;
293
297 virtual void StopMotion() const = 0;
299
300 private:
301 void ResetImpl(dispatch_tag<InstrumentBase>) override final;
303 };
304}
Implementation of DynExp instrument objects.
Configurator class for PositionerStage.
Definition Stage.h:142
Data class for PositionerStage.
Definition Stage.h:66
bool HasFailed() const noexcept
Returns whether the stage is in an error state, i.e. moving has failed (result of HasFailedChild())
Definition Stage.h:83
PositionType Velocity
Velocity in nm/s if the respective stage supports SI units. Otherwise, in units of steps/s.
Definition Stage.h:112
auto GetCurrentPosition() const noexcept
Returns Position.
Definition Stage.h:76
signed long long PositionType
Numeric type to store the stage positions.
Definition Stage.h:71
bool IsMoving() const noexcept
Returns whether the stage is currently moving (result of IsMovingChild())
Definition Stage.h:81
void SetCurrentPosition(PositionType Position) noexcept
Sets Position to Position.
Definition Stage.h:78
void SetVelocity(PositionType Velocity) noexcept
Sets Velocity to Velocity.
Definition Stage.h:79
void ResetImpl(dispatch_tag< InstrumentDataBase >) override final
Definition Stage.cpp:8
virtual ~PositionerStageData()=default
PositionType Position
Position in nm if the respective stage supports SI units. Otherwise, in units of steps performed.
Definition Stage.h:107
virtual bool IsMovingChild() const noexcept=0
Returns whether the stage is currently moving (result of IsMovingChild())
virtual bool IsReferencedChild() const noexcept
Returns whether a closed-loop positioner knows its position in respect to its zero point (result of I...
Definition Stage.h:101
virtual bool HasArrivedChild() const noexcept=0
Returns whether the stage has arrived at its destiny position (result of HasArrivedChild())
bool IsReferenced() const noexcept
Returns whether a closed-loop positioner knows its position in respect to its zero point (result of I...
Definition Stage.h:84
virtual bool HasFailedChild() const noexcept=0
Returns whether the stage is in an error state, i.e. moving has failed (result of HasFailedChild())
virtual void ResetImpl(dispatch_tag< PositionerStageData >)
Refer to DynExp::InstrumentDataBase::Reset(). Using tag dispatch mechanism to ensure that ResetImpl()...
Definition Stage.h:92
bool HasArrived() const noexcept
Returns whether the stage has arrived at its destiny position (result of HasArrivedChild())
Definition Stage.h:82
auto GetVelocity() const noexcept
Returns Velocity.
Definition Stage.h:77
Parameter class for PositionerStage.
Definition Stage.h:119
PositionerStageParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
Constructs the parameters for a PositionerStage instance.
Definition Stage.h:125
DummyParam Dummy
Dummy parameter which is to be owned once by parameter classes that do not contain any other paramete...
Definition Stage.h:135
void ConfigureParamsImpl(dispatch_tag< InstrumentParamsBase >) override final
Definition Stage.h:132
virtual void ConfigureParamsImpl(dispatch_tag< PositionerStageParams >)
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
Definition Stage.h:133
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 Stage.h:129
Defines a task for deinitializing an instrument within an instrument inheritance hierarchy....
Definition Stage.h:39
virtual void ExitFuncImpl(dispatch_tag< ExitTask >, DynExp::InstrumentInstance &Instance)
Deinitializes the respective instrument within the instrument inheritance hierarchy....
Definition Stage.h:45
void ExitFuncImpl(dispatch_tag< ExitTaskBase >, DynExp::InstrumentInstance &Instance) override final
Definition Stage.h:40
Defines a task for initializing an instrument within an instrument inheritance hierarchy....
Definition Stage.h:26
virtual void InitFuncImpl(dispatch_tag< InitTask >, DynExp::InstrumentInstance &Instance)
Initializes the respective instrument within the instrument inheritance hierarchy....
Definition Stage.h:32
void InitFuncImpl(dispatch_tag< InitTaskBase >, DynExp::InstrumentInstance &Instance) override final
Definition Stage.h:27
Defines a task for updating an instrument within an instrument inheritance hierarchy....
Definition Stage.h:52
void UpdateFuncImpl(dispatch_tag< UpdateTaskBase >, DynExp::InstrumentInstance &Instance) override final
Definition Stage.h:53
virtual void UpdateFuncImpl(dispatch_tag< UpdateTask >, DynExp::InstrumentInstance &Instance)
Updates the respective instrument within the instrument inheritance hierarchy. Call UpdateFuncImpl() ...
Definition Stage.h:58
Implementation of a meta instrument to control single-axis positioner stages.
Definition Stage.h:155
static constexpr auto Name() noexcept
Every derived class has to redefine this function.
Definition Stage.h:183
virtual PositionerStageData::PositionType GetMinPosition() const noexcept=0
Returns the minimal position the stage can move to in nm if the stage supports SI units,...
static constexpr auto Category() noexcept
Every derived class has to redefine this function.
Definition Stage.h:184
virtual std::string GetCategory() const override
Returns the category of this Object type.
Definition Stage.h:195
virtual void MoveAbsolute(const PositionerStageData::PositionType Steps, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const =0
Moves the positioner to an absolute position in its native units. Do divide units of PositionerStageD...
PositionerStage(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Constructs an instrument instance.
Definition Stage.h:189
virtual void MoveRelative(const PositionerStageData::PositionType Steps, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const =0
Moves the positioner to a position relative to its current position. The position offset Steps has to...
virtual std::string GetName() const override
Returns the name of this Object type.
Definition Stage.h:194
virtual PositionerStageData::PositionType GetDefaultVelocity() const noexcept=0
Returns the stage's default velocity in nm/s if the stage supports SI units, in steps/s otherwise.
virtual void Reference(DirectionType Direction=DirectionType::Forward, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
References the positioner such that it finds its zero position or end stop.
Definition Stage.cpp:33
void ResetImpl(dispatch_tag< InstrumentBase >) override final
Definition Stage.cpp:48
virtual std::chrono::milliseconds GetTaskQueueDelay() const override
Specifies in which time intervals the instrument's task queue runs to handle pending tasks.
Definition Stage.h:197
virtual void Calibrate(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Calibrates the positioner. The meaning of such a calibration is solely specified by the hardware manu...
Definition Stage.cpp:38
virtual void SetVelocity(const PositionerStageData::PositionType Velocity) const =0
Sets the positioner's velocity in its native units. Do divide units of PositionerStageData::Velocity ...
virtual PositionerStageData::PositionType GetMinVelocity() const noexcept=0
Returns the minimal velocity the stage can move with in nm/s if the stage supports SI units,...
virtual PositionerStageData::PositionType GetResolution() const noexcept=0
Returns the stage's position resolution (precision) in nm if the stage supports SI units,...
virtual void StopMotion() const =0
Stops any motion or position stabilization of the positioner immediately.
virtual bool IsUsingSIUnits() const noexcept
Determines whether the underlying hardware expects SI units for positions and velocities or arbitrary...
Definition Stage.h:224
virtual void ResetImpl(dispatch_tag< PositionerStage >)=0
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
virtual PositionerStageData::PositionType GetMaxPosition() const noexcept=0
Returns the maximal position the stage can move to in nm if the stage supports SI units,...
virtual void MoveToHome(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Moves the positioner to its stored home position. Also refer to SetHome().
Definition Stage.cpp:43
virtual PositionerStageData::PositionType GetMaxVelocity() const noexcept=0
Returns the maximal velocity the stage can move with in nm/s if the stage supports SI units,...
DirectionType
Type to determine the direction of the positioner stage's movements.
Definition Stage.h:160
virtual ~PositionerStage()=0
Definition Stage.cpp:24
virtual double GetStepNanoMeterRatio() const noexcept
Determines the conversion factor in between internal PositionerStageData::PositionType positiond and ...
Definition Stage.h:217
virtual void SetHome() const
Stores the positioner's home position. Also refer to MoveToHome().
Definition Stage.cpp:28
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Definition DynExpCore.h:127
Defines a task for deinitializing an instrument within an instrument inheritance hierarchy....
Refer to DynExp::ParamsBase::dispatch_tag.
Defines a task for initializing an instrument within an instrument inheritance hierarchy....
Refer to DynExp::ParamsBase::dispatch_tag.
Base class for instruments. Instruments comprise virtual devices (meta instruments) and physial devic...
Definition Instrument.h:451
InstrumentBase(const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params)
Constructs an instrument instance.
Configurator class for InstrumentBase.
Definition Instrument.h:435
Data structure to contain data which is synchronized in between different threads....
Definition Instrument.h:135
Refer to ParamsBase::dispatch_tag.
Definition Instrument.h:146
Defines data for a thread belonging to a InstrumentBase instance. Refer to RunnableInstance.
Definition Instrument.h:772
Parameter class for InstrumentBase.
Definition Instrument.h:401
InstrumentParamsBase(ItemIDType ID, const DynExpCore &Core)
Constructs the parameters for a InstrumentBase instance.
Definition Instrument.h:412
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
Dummy parameter which is to be owned once by parameter classes that do not contain any other paramete...
Definition Object.h:522
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
std::function< void(const TaskBase &, ExceptionContainer &)> CallbackType
Type of a callback function which is invoked when a task has finished, failed or has been aborted....
Definition Instrument.h:939
Defines a task for updating an instrument within an instrument inheritance hierarchy....
Refer to DynExp::ParamsBase::dispatch_tag.
DynExp's instrument namespace contains the implementation of DynExp instruments which extend DynExp's...
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.
Accumulates include statements to provide a precompiled header.