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);
48 if (std::isnan(ModuleData->CurrentFrequency))
50 ui->LActualFrequency->setText(
"Output unstable");
51 ui->LActualWavelength->setText(
"Output unstable");
57 ui->LActualFrequency->setText(QString::number(ModuleData->CurrentFrequency * 1e-12,
'f', 6) +
" THz");
59 ui->LActualFrequency->setStyleSheet(
"");
60 ui->LActualWavelength->setStyleSheet(
"");
63 if (ModuleData->CurrentIntensity < ModuleData->HardwareMinIntensity)
65 ui->LActualIntensity->setText(QString::number(ModuleData->CurrentIntensity * 1e3,
'f', 3) +
" mW (Power low)");
70 ui->LActualIntensity->setText(QString::number(ModuleData->CurrentIntensity * 1e3,
'f', 3) +
" mW");
71 ui->LActualIntensity->setStyleSheet(
"");
74 if (!
ui->SBScanRange->hasFocus())
76 const QSignalBlocker Blocker(
ui->SBScanRange);
77 ui->SBScanRange->setValue(ModuleData->CurrentScanRange * 1e-9);
80 if (!
ui->SBScanRate->hasFocus())
82 const QSignalBlocker Blocker(
ui->SBScanRate);
83 ui->SBScanRate->setValue(ModuleData->CurrentScanRate * 1e-9);
86 switch (ModuleData->LaserState)
89 ui->LState->setText(
" Startup...");
93 ui->LState->setText(
" Emitting in constant mode.");
97 ui->LState->setText(
" Emitting in scanning mode.");
101 ui->LState->setText(
" The Laser is in an error state.");
105 ui->LState->setText(
" Laser is ready for emission.");
190 auto InstrData = DynExp::dynamic_InstrumentData_cast<DynExpInstr::Laser>(
ModuleData->GetLaser()->GetInstrumentData());
192 ModuleData->CurrentFrequency =
ModuleData->FrequencyInLaserUnitToHz(InstrData->GetFrequencyValue());
193 ModuleData->CurrentIntensity =
ModuleData->IntensityInLaserUnitToW(InstrData->GetIntensityValue());
194 ModuleData->CurrentScanRange =
ModuleData->FrequencyInLaserUnitToHz(InstrData->GetScanRangeValue());
195 ModuleData->CurrentScanRate =
ModuleData->FrequencyInLaserUnitToHz(InstrData->GetScanRateValue());
196 ModuleData->LaserState = InstrData->GetLaserState();
216 auto Widget = std::make_unique<LaserControlWidget>(*
this);
231 auto Widget = GetWidget<LaserControlWidget>();
232 auto ModuleData = DynExp::dynamic_ModuleData_cast<LaserControl>(ModuleDataGetter());
245 auto ModuleParams = DynExp::dynamic_Params_cast<LaserControl>(Instance->
ParamsGetter());
295 if (
ModuleData->CurrentFrequency != FrequencyInHz)
303 const double FrequencyInHz = Value * 1e12;
304 if (
ModuleData->CurrentFrequency != FrequencyInHz)
312 const double IntensityInW = Value * 1e-3;
313 if (
ModuleData->CurrentIntensity != IntensityInW)
321 const double FrequencyInHz = Value * 1e9;
322 if (
ModuleData->CurrentScanRange != FrequencyInHz)
330 const double FrequencyInHz = Value * 1e9;
331 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.
double HardwareMaxScanRange
double IntensityInLaserUnitToW(double Value) const
double HardwareMinScanRange
double HardwareMaxIntensity
DynExp::Units::UnitType FrequencyUnit
double HardwareMinScanRate
void ResetImpl(dispatch_tag< QModuleDataBase >) override final
double FrequencyInLaserUnitToHz(double Value) const
double FrequencyInHzToLaserUnit(double Value) const
double IntensityInWToLaserUnit(double Value) const
double HardwareMaxFrequency
DynExpInstr::LaserData::LaserStateType LaserState
double HardwareModeHopFreeTuningRange
DynExp::Units::UnitType IntensityUnit
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
@ Freq_Hz
Frequency in Hz.
@ Wavelength_nm
Wavelength in nm.
@ Power_W
Power in Watt (W)
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.