4#include "moc_LaserControl.cpp"
5#include "ui_LaserControl.h"
11 : QModuleWidget(Owner, parent),
17 this->addAction(
ui->action_Enable);
22 const QSignalBlocker SBFrequencyBlocker(
ui->SBFrequency);
23 ui->SBFrequency->setRange(ModuleData->HardwareMinFrequency * 1e-12, ModuleData->HardwareMaxFrequency * 1e-12);
24 ui->SBFrequency->setValue(ModuleData->HardwareMinFrequency * 1e-12);
26 const QSignalBlocker SBWavelengthBlocker(
ui->SBWavelength);
30 const QSignalBlocker SBIntensityBlocker(
ui->SBIntensity);
31 ui->SBIntensity->setRange(ModuleData->HardwareMinIntensity * 1e3, ModuleData->HardwareMaxIntensity * 1e3);
32 ui->SBIntensity->setValue(ModuleData->HardwareMinIntensity * 1e3);
34 const QSignalBlocker SBScanRangeBlocker(
ui->SBScanRange);
35 ui->SBScanRange->setRange(ModuleData->HardwareMinScanRange * 1e-9, ModuleData->HardwareMaxScanRange * 1e-9);
37 const QSignalBlocker SBScanRateBlocker(
ui->SBScanRate);
38 ui->SBScanRate->setRange(ModuleData->HardwareMinScanRate * 1e-9, ModuleData->HardwareMaxScanRate * 1e-9);
40 ui->GBFrequencyWavelength->setVisible(ModuleData->HardwareMinFrequency != ModuleData->HardwareMaxFrequency);
41 ui->GBIntensity->setVisible(ModuleData->HardwareMinIntensity != ModuleData->HardwareMaxIntensity);
42 ui->GBScanSettings->setVisible(ModuleData->HardwareMinScanRange != ModuleData->HardwareMaxScanRange);
43 ui->action_Scan->setEnabled(ModuleData->HardwareMinScanRange != ModuleData->HardwareMaxScanRange);
55 if (std::isnan(ModuleData->CurrentFrequency))
57 ui->LActualFrequency->setText(
"Output unstable");
58 ui->LActualWavelength->setText(
"Output unstable");
64 ui->LActualFrequency->setText(QString::number(ModuleData->CurrentFrequency * 1e-12,
'f', 6) +
" THz");
66 ui->LActualFrequency->setStyleSheet(
"");
67 ui->LActualWavelength->setStyleSheet(
"");
70 if (ModuleData->CurrentIntensity < ModuleData->HardwareMinIntensity)
72 ui->LActualIntensity->setText(QString::number(ModuleData->CurrentIntensity * 1e3,
'f', 3) +
" mW (Power low)");
77 ui->LActualIntensity->setText(QString::number(ModuleData->CurrentIntensity * 1e3,
'f', 3) +
" mW");
78 ui->LActualIntensity->setStyleSheet(
"");
81 if (!
ui->SBScanRange->hasFocus())
83 const QSignalBlocker Blocker(
ui->SBScanRange);
84 ui->SBScanRange->setValue(ModuleData->CurrentScanRange * 1e-9);
87 if (!
ui->SBScanRate->hasFocus())
89 const QSignalBlocker Blocker(
ui->SBScanRate);
90 ui->SBScanRate->setValue(ModuleData->CurrentScanRate * 1e-9);
93 switch (ModuleData->LaserState)
96 ui->LState->setText(
" Startup...");
100 ui->LState->setText(
" Emitting in constant mode.");
104 ui->LState->setText(
" Emitting in scanning mode.");
108 ui->LState->setText(
" The Laser is in an error state.");
112 ui->LState->setText(
" Laser is ready for emission.");
197 auto InstrData = DynExp::dynamic_InstrumentData_cast<DynExpInstr::Laser>(
ModuleData->GetLaser()->GetInstrumentData());
199 ModuleData->CurrentFrequency =
ModuleData->FrequencyInLaserUnitToHz(InstrData->GetFrequencyValue());
200 ModuleData->CurrentIntensity =
ModuleData->IntensityInLaserUnitToW(InstrData->GetIntensityValue());
201 ModuleData->CurrentScanRange =
ModuleData->FrequencyInLaserUnitToHz(InstrData->GetScanRangeValue());
202 ModuleData->CurrentScanRate =
ModuleData->FrequencyInLaserUnitToHz(InstrData->GetScanRateValue());
203 ModuleData->LaserState = InstrData->GetLaserState();
223 auto Widget = std::make_unique<LaserControlWidget>(*
this);
238 auto Widget = GetWidget<LaserControlWidget>();
239 auto ModuleData = DynExp::dynamic_ModuleData_cast<LaserControl>(ModuleDataGetter());
252 auto ModuleParams = DynExp::dynamic_Params_cast<LaserControl>(Instance->
ParamsGetter());
302 if (
ModuleData->CurrentFrequency != FrequencyInHz)
310 const double FrequencyInHz = Value * 1e12;
311 if (
ModuleData->CurrentFrequency != FrequencyInHz)
319 const double IntensityInW = Value * 1e-3;
320 if (
ModuleData->CurrentIntensity != IntensityInW)
328 const double FrequencyInHz = Value * 1e9;
329 if (
ModuleData->CurrentScanRange != FrequencyInHz)
337 const double FrequencyInHz = Value * 1e9;
338 if (
ModuleData->CurrentScanRate != FrequencyInHz)
Implementation of a module to control a laser source.
@ Startup
The laser is warming up.
@ Error
The laser is in an error state.
@ EmissionEnabledConstant
The laser is emitting in constant mode.
@ EmissionEnabledScanning
The laser is emitting in scan mode.
@ Ready
The laser is ready for emission.
@ Power_W
Power in Watt (W)
double HardwareMaxScanRange
double IntensityInLaserUnitToW(double Value) const
DynExpInstr::LaserData::IntensityUnitType IntensityUnit
double HardwareMinScanRange
double HardwareMaxIntensity
double HardwareMinScanRate
void ResetImpl(dispatch_tag< QModuleDataBase >) override final
double FrequencyInLaserUnitToHz(double Value) const
double FrequencyInHzToLaserUnit(double Value) const
double IntensityInWToLaserUnit(double Value) const
DynExpInstr::LaserData::FrequencyUnitType FrequencyUnit
double HardwareMaxFrequency
DynExpInstr::LaserData::LaserStateType LaserState
double HardwareModeHopFreeTuningRange
double HardwareMinIntensity
double HardwareMaxScanRate
double HardwareMinFrequency
void OnScanToggled(DynExp::ModuleInstance *Instance, bool) const
void OnWavelengthValueChanged(DynExp::ModuleInstance *Instance, double Wavelength) const
void OnIntensityValueChanged(DynExp::ModuleInstance *Instance, double Intensity) 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...
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...
void UpdateUIChild(const ModuleBase::ModuleDataGetterType &ModuleDataGetter) override final
void OnScanRangeValueChanged(DynExp::ModuleInstance *Instance, double ScanRange) const
void OnScanRateValueChanged(DynExp::ModuleInstance *Instance, double ScanRate) const
void OnExit(DynExp::ModuleInstance *Instance) const override final
This event is triggered right before the module thread terminates (not due to an exception,...
size_t NumFailedUpdateAttempts
void ResetImpl(dispatch_tag< QModuleBase >) override final
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...
void OnFrequencyValueChanged(DynExp::ModuleInstance *Instance, double Frequency) const
void OnEnableToggled(DynExp::ModuleInstance *Instance, bool) const
const std::unique_ptr< ModuleDataType > ModuleData
Module data belonging to this ModuleBase instance.
Refer to ParamsBase::dispatch_tag.
Defines data for a thread belonging to a ModuleBase instance. Refer to RunnableInstance.
const ModuleBase::ModuleDataGetterType ModuleDataGetter
Getter for module's data. Refer to ModuleBase::ModuleDataGetterType.
Refer to ParamsBase::dispatch_tag.
QModuleWidget * Widget
User interface widget belonging to the module.
void Connect(SenderType *Sender, SignalType Signal, ReceiverType *Receiver, EventType Event)
Uses Qt's connect mechanism to connect a QObject's signal to a DynExp module's event....
const Object::ParamsGetterType ParamsGetter
Invoke to obtain the parameters (derived from ParamsBase) of Owner.
void UnlockObject(LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer)
Unlocks an Object instance stored in the LinkedObjectWrapperContainer ObjectWrapperContainer....
void LockObject(const ParamsBase::Param< ObjectLink< ObjectT > > &LinkParam, LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer, std::chrono::milliseconds Timeout=ObjectLinkBase::LockObjectTimeoutDefault)
Locks an Object instance referenced by a parameter LinkParam of type ParamsBase::Param< ObjectLink< O...
const auto & GetOwner() const noexcept
Returns Owner.
Thrown when a requested feature is either under development and thus not implemented yet or when a sp...
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads....
Thrown when an operation timed out before it could be completed, especially used for locking shared d...
DynExp's module namespace contains the implementation of DynExp modules which extend DynExp's core fu...
constexpr auto StatusBarWarningStyleSheet
constexpr auto StatusBarReadyStyleSheetBright
constexpr auto StatusBarErrorStyleSheet
constexpr auto StatusBarBusyStyleSheet
DynExpErrorCodes
DynExp's error codes
constexpr auto ConvertFrequencyWavelength(double Value) noexcept
Converts the frequency value of an electromagnetic wave in Hz to the corresponding wavelength in m an...
Accumulates include statements to provide a precompiled header.