1
////////////////////////////////////////////////////////////////////////////////
2
/*! @file DummyTunableCCDDriver.cpp Имитатор драйвера ПЗС-линейки с перестройкой длины волны.
3
- Part of DemoDevices - Research Assistant Plugin package.
4
- Uses RAGUI - Research Assistant Graphical User Interface Library.
5
- Uses Qt v.5.0.2 - http://qt-project.org/
6
- Uses RANet - Research Assistant Net Library.
7
- Copyright(C) 2017, Dmitrii Nelson, St.Petersburg, Russia.
9
*///////////////////////////////////////////////////////////////////////////////
10
#include "DummyTunableCCDDriver.h"
17
//------------------------------------------------------------------------------
19
DEFINE_CLASS_TAG(sDummyTunableCCDDriver)
21
//-------------------------------------------- sDummyTunableCCDDriver ----------
23
void sDummyTunableCCDDriver::Preconfigure (sNodePtr DeviceCfg)
25
sPtr<sFolderNode> DeviceSettings;
26
DeviceCfg |= "Settings";
27
DeviceSettings = DeviceCfg >> "Settings";
28
if( DeviceSettings.IsCorrect() ){
29
DeviceSettings |= attr("NumberOfPixels",3648);
30
DeviceSettings |= attr("MiddlePixel",1733);
31
DeviceSettings |= attr("WL_0",sPhysValue(0.02389,"nm"));
32
DeviceSettings |= attr("WL_k",sPhysValue(-7.8e-6,_Unitsless_));
34
sTunableCCDDriver::Preconfigure(DeviceCfg);
37
sDummyTunableCCDDriver::~sDummyTunableCCDDriver ()
41
sDummyTunableCCDDriver::sDummyTunableCCDDriver (sString DevicetId
43
:sTunableCCDDriver(DevicetId,DeviceCfg)
45
,WL_0(sPhysValue(1.0,"nm"))
46
,WL_k(sPhysValue(1,_Unitsless_))
50
void sDummyTunableCCDDriver::PostConstructor ()
52
sTunableCCDDriver::PostConstructor();
53
try{ //get config parameters
54
get_from<sPhysValueNode>(DeviceSettings >> "WL_0" ,WL_0);
55
get_from<sPhysValueNode>(DeviceSettings >> "WL_k" ,WL_k);
57
SetInvalid(tr("Something wrong in configuration."));
61
void sDummyTunableCCDDriver::ConnectUSBDevice ()
66
void sDummyTunableCCDDriver::GetCCD_Data ()
68
ushort NoiseDivider = RAND_MAX/320;
69
Amplitude = Amplitude - 1000;
70
if (Amplitude < 2000) Amplitude = 50000;
72
for(int i = 0;i < NumOfPixels; i ++) {
73
DataArray.ArrBody[i] = Amplitude/(1+(i-NumOfPixels/2)*(i-NumOfPixels/2)/Width)
74
+std::rand()/NoiseDivider;
76
emit NewData(DataArray);
79
void sDummyTunableCCDDriver::CalculateWavelengths ()
81
sPhysValue dWL = WL_0 + WL_k * WLPosition;
82
sPhysValue LeftPos = WLPosition - dWL*MiddlePixel;
83
sPhysValue RightPos = WLPosition + dWL*((NumOfPixels -1) - MiddlePixel);
84
real dX_0 = ((WL_0 + WL_k * LeftPos)/(sPhysValue(1.0,"nm"))).ToReal();
85
real dX_1 = ((WL_0 + WL_k * RightPos)/(sPhysValue(1.0,"nm"))).ToReal();
86
real dX = (dWL/(sPhysValue(1.0,"nm"))).ToReal(); // in "nm/pixel"
87
real d2X = (dX_1 - dX_0)/NumOfPixels;
88
real XM = (WLPosition/(sPhysValue(1.0,"nm"))).ToReal(); // in "nm"
89
for (int i = 0; i < NumOfPixels; i++) {
90
Wavelengths.ArrBody[i] = XM + (dX + d2X *(i - MiddlePixel))*(i - MiddlePixel);
92
emit NewWavelengths (Wavelengths);
95
void sDummyTunableCCDDriver::StartCCD ()
97
int _IT = Parameters.IntegrationTime / 1000;
99
State_O_Measuring->SetTimeout(_IT);
102
void sDummyTunableCCDDriver::StopCCD ()
104
WLDriver.ReleaseExclusiveControl();
107
void sDummyTunableCCDDriver::SetCCD_Parameters (sCCDDriver::sParameters Params)
109
if( ! WLDriver.TakeExclusiveControl() ){
117
//------------------------------------------------------------------------------