15 #include "ui_lockinampform.h"
16 #include "lockinamp.h"
17 #include "interface.h"
19 #include "xnodeconnector.h"
22 XLIA::XLIA(
const char *name,
bool runtime,
23 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
26 dynamic_pointer_cast<
XDriver>(shared_from_this()))),
28 dynamic_pointer_cast<
XDriver>(shared_from_this()))),
30 m_frequency(create<
XDoubleNode>(
"Frequency", false)),
31 m_sensitivity(create<
XComboNode>(
"Sensitivity", false, true)),
32 m_timeConst(create<
XComboNode>(
"TimeConst", false, true)),
33 m_autoScaleX(create<
XBoolNode>(
"AutoScaleX", false)),
34 m_autoScaleY(create<
XBoolNode>(
"AutoScaleY", false)),
35 m_fetchFreq(create<
XDoubleNode>(
"FetchFreq", false)),
36 m_form(new
FrmLIA(g_pFrmMain)) {
38 tr[ *fetchFreq()] = 1;
41 meas->scalarEntries()->insert(tr_meas, m_valueX);
42 meas->scalarEntries()->insert(tr_meas, m_valueY);
44 m_form->statusBar()->hide();
45 m_form->setWindowTitle(i18n(
"Lock-in-Amp - ") +
getLabel() );
47 m_output->setUIEnabled(
false);
48 m_frequency->setUIEnabled(
false);
49 m_sensitivity->setUIEnabled(
false);
50 m_timeConst->setUIEnabled(
false);
51 m_autoScaleX->setUIEnabled(
false);
52 m_autoScaleY->setUIEnabled(
false);
53 m_fetchFreq->setUIEnabled(
false);
55 m_conSens = xqcon_create<XQComboBoxConnector>(m_sensitivity, m_form->m_cmbSens,
Snapshot( *m_sensitivity));
56 m_conTimeConst = xqcon_create<XQComboBoxConnector>(m_timeConst, m_form->m_cmbTimeConst,
Snapshot( *m_timeConst));
57 m_conFreq = xqcon_create<XQLineEditConnector>(m_frequency, m_form->m_edFreq);
58 m_conOutput = xqcon_create<XQLineEditConnector>(m_output, m_form->m_edOutput);
59 m_conAutoScaleX = xqcon_create<XQToggleButtonConnector>(m_autoScaleX, m_form->m_ckbAutoScaleX);
60 m_conAutoScaleY = xqcon_create<XQToggleButtonConnector>(m_autoScaleY, m_form->m_ckbAutoScaleY);
61 m_conFetchFreq = xqcon_create<XQLineEditConnector>(m_fetchFreq, m_form->m_edFetchFreq);
74 x = reader.pop<
double>();
75 y = reader.pop<
double>();
76 m_valueX->value(tr, x);
77 m_valueY->value(tr, y);
86 changeOutput(shot[ *output()]);
89 e.print(
getLabel() +
" " + i18n(
"Error while changing output, "));
96 changeFreq(shot[ *frequency()]);
99 e.print(
getLabel() +
" " + i18n(
"Error while changing frequency, "));
106 changeSensitivity(shot[ *sensitivity()]);
109 e.print(
getLabel() +
" " + i18n(
"Error while changing sensitivity, "));
116 changeTimeConst(shot[ *timeConst()]);
119 e.print(
getLabel() +
" " + i18n(
"Error while changing time const., "));
126 m_output->setUIEnabled(
true);
127 m_frequency->setUIEnabled(
true);
128 m_sensitivity->setUIEnabled(
true);
129 m_timeConst->setUIEnabled(
true);
130 m_autoScaleX->setUIEnabled(
true);
131 m_autoScaleY->setUIEnabled(
true);
132 m_fetchFreq->setUIEnabled(
true);
135 m_lsnOutput = tr[ *output()].onValueChanged().connectWeakly(
136 shared_from_this(), &XLIA::onOutputChanged);
137 m_lsnFreq = tr[ *frequency()].onValueChanged().connectWeakly(
138 shared_from_this(), &XLIA::onFreqChanged);
139 m_lsnSens = tr[ *sensitivity()].onValueChanged().connectWeakly(
140 shared_from_this(), &XLIA::onSensitivityChanged);
141 m_lsnTimeConst = tr[ *timeConst()].onValueChanged().connectWeakly(
142 shared_from_this(), &XLIA::onTimeConstChanged);
145 while( !terminated) {
146 double fetch_freq = ***fetchFreq();
149 sscanf(( **timeConst())->to_str().c_str(),
"%lf", &wait);
150 wait *= 1000.0 / fetch_freq;
152 if(wait > 0) msecsleep(lrint(wait));
155 XTime time_awared = XTime::now();
161 e.print(
getLabel() +
" " + i18n(
"Read Error, "));
164 auto writer = std::make_shared<RawData>();
169 m_output->setUIEnabled(
false);
170 m_frequency->setUIEnabled(
false);
171 m_sensitivity->setUIEnabled(
false);
172 m_timeConst->setUIEnabled(
false);
173 m_autoScaleX->setUIEnabled(
false);
174 m_autoScaleY->setUIEnabled(
false);
175 m_fetchFreq->setUIEnabled(
false);
180 m_lsnTimeConst.reset();