-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget.cpp
More file actions
695 lines (610 loc) · 22.9 KB
/
widget.cpp
File metadata and controls
695 lines (610 loc) · 22.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
#include <QButtonGroup>
#include <QComboBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QLayout>
#include <QPushButton>
#include <QTimer>
#include "widget.hpp"
#include <rtxi/daq.hpp>
#include <rtxi/debug.hpp>
Q_DECLARE_METATYPE(DAQ::Device*)
am_amp2400::AMAmpComboBox::AMAmpComboBox(QWidget* parent)
: QComboBox(parent)
{
QObject::connect(
this, SIGNAL(currentIndexChanged(int)), this, SLOT(redden()));
}
void am_amp2400::AMAmpComboBox::blacken()
{
this->setStyleSheet("QComboBox { color:black; }");
}
void am_amp2400::AMAmpComboBox::redden()
{
this->setStyleSheet("QComboBox { color:red; }");
}
/// Create wrapper for QLineEdit. Options go red when changed and black when
/// 'Set DAQ' is hit.
am_amp2400::AMAmpLineEdit::AMAmpLineEdit(QWidget* parent)
: QLineEdit(parent)
{
QObject::connect(
this, SIGNAL(textEdited(const QString&)), this, SLOT(redden()));
}
void am_amp2400::AMAmpLineEdit::blacken()
{
this->setStyleSheet("QLineEdit { color:black; }");
}
void am_amp2400::AMAmpLineEdit::redden()
{
this->setStyleSheet("QLineEdit { color:red; }");
}
am_amp2400::AMAmpSpinBox::AMAmpSpinBox(QWidget* parent)
: QSpinBox(parent)
{
QObject::connect(this, SIGNAL(valueChanged(int)), this, SLOT(redden()));
}
void am_amp2400::AMAmpSpinBox::blacken()
{
this->setStyleSheet("QSpinBox { color:black; }");
}
void am_amp2400::AMAmpSpinBox::redden()
{
this->setStyleSheet("QSpinBox { color:red; }");
}
am_amp2400::Plugin::Plugin(Event::Manager* ev_manager)
: Widgets::Plugin(ev_manager, std::string(am_amp2400::MODULE_NAME))
{
}
am_amp2400::Panel::Panel(QMainWindow* main_window, Event::Manager* ev_manager)
: Widgets::Panel(
std::string(am_amp2400::MODULE_NAME), main_window, ev_manager)
{
setWhatsThis(
"<p>Controls the AM Amp 2400 amplifier by scaling the gains on the "
"analog input/output channels and sending a mode telegraph to set the "
"amplifier mode (custom).</p>");
// We generate the default parameters in the panel but avoid displaying it
// as this module creates it's own custom gui elements
// createGUI(am_amp2400::get_default_vars(), {});
// Get list of devices to control amplifier
this->customizeGUI();
QTimer::singleShot(0, this, SLOT(resizeMe()));
}
void am_amp2400::Panel::initParameters()
{
input_channel = 0;
output_channel = 0;
mode = amp_mode::IEQ0;
ai_offset = 0.0;
ao_offset = 0.0;
digital_line_0 = 0;
digital_line_1 = 0;
digital_line_2 = 0;
zero_offset = 0;
signal_count = 0;
// these are amplifier-specific settings.
// These values used to be assignable in past iterations of this plugin.
// However what is the point of mutable variables when they are inherent
// to the amplifier and never modified? now they are set at
// compile-time and constant.
//
// iclamp_ai_gain = 200e-3;
// iclamp_ao_gain = 500e6;
// izero_ai_gain = 200e-3;
// izero_ao_gain = 1;
// vclamp_ai_gain = 2e-9;
// vclamp_ao_gain = 50;
}
void am_amp2400::Panel::customizeGUI()
{
// QGridLayout* customLayout = DefaultGUIModel::getLayout();
// auto* widget_layout = dynamic_cast<QVBoxLayout*>(this->layout());
// Since we don't use the default layout construction provided by RTXI we
// opt to create our own layout. Note that this is essentially just a
// QVBoxLayout class that rtxi gives us, so that's what we'll create here.
auto* widget_layout = new QVBoxLayout;
// We get a list of devices so that they are available for selection in
// the combobox
Event::Object device_list_request(Event::Type::DAQ_DEVICE_QUERY_EVENT);
this->getRTXIEventManager()->postEvent(&device_list_request);
auto devices = std::any_cast<std::vector<DAQ::Device*>>(
device_list_request.getParam("devices"));
devicesComboBox = new QComboBox();
for (auto* device : devices) {
devicesComboBox->addItem(QString::fromStdString(device->getName()),
QVariant::fromValue(device));
}
widget_layout->addWidget(devicesComboBox);
// create input spinboxes
auto* ioGroupBox = new QGroupBox("Channels");
auto* ioGroupLayout = new QGridLayout;
ioGroupBox->setLayout(ioGroupLayout);
auto* inputBoxLabel = new QLabel("Input");
inputBox = new AMAmpSpinBox; // this is the QSpinBox wrapper made earlier
inputBox->setRange(0, 100);
ioGroupLayout->addWidget(inputBoxLabel, 0, 0);
ioGroupLayout->addWidget(inputBox, 0, 1);
auto* outputBoxLabel = new QLabel("Output");
outputBox = new AMAmpSpinBox;
outputBox->setRange(0, 100);
ioGroupLayout->addWidget(outputBoxLabel, 1, 0);
ioGroupLayout->addWidget(outputBox, 1, 1);
auto* bit1BoxLabel = new QLabel("Mode Bit 1");
bit1Box = new AMAmpSpinBox;
bit1Box->setRange(0, 100);
ioGroupLayout->addWidget(bit1BoxLabel, 2, 0);
ioGroupLayout->addWidget(bit1Box, 2, 1);
auto* bit2BoxLabel = new QLabel("Mode Bit 2");
bit2Box = new AMAmpSpinBox;
bit2Box->setRange(0, 100);
ioGroupLayout->addWidget(bit2BoxLabel, 3, 0);
ioGroupLayout->addWidget(bit2Box, 3, 1);
auto* bit4BoxLabel = new QLabel("Mode Bit 4");
bit4Box = new AMAmpSpinBox;
bit4Box->setRange(0, 100);
ioGroupLayout->addWidget(bit4BoxLabel, 4, 0);
ioGroupLayout->addWidget(bit4Box, 4, 1);
// create amp mode groupbox
auto* ampModeGroupBox = new QGroupBox("Amp Mode");
auto* ampModeGroupLayout = new QGridLayout;
ampModeGroupBox->setLayout(ampModeGroupLayout);
auto* offsetLayout = new QGridLayout;
offsetLayout->setColumnStretch(0, 1);
auto* aiOffsetLabel = new QLabel("AI Offset:");
offsetLayout->addWidget(aiOffsetLabel, 0, 0);
aiOffsetEdit = new AMAmpLineEdit();
aiOffsetEdit->setMaximumWidth(aiOffsetEdit->minimumSizeHint().width() * 3);
aiOffsetEdit->setValidator(new QDoubleValidator(aiOffsetEdit));
offsetLayout->addWidget(aiOffsetEdit, 0, 1);
aiOffsetUnits = new QLabel;
aiOffsetUnits->setText("1 V/V");
offsetLayout->addWidget(aiOffsetUnits, 0, 2, Qt::AlignCenter);
auto* aoOffsetLabel = new QLabel("AO Offset:");
offsetLayout->addWidget(aoOffsetLabel, 1, 0);
aoOffsetEdit = new AMAmpLineEdit();
aoOffsetEdit->setMaximumWidth(aoOffsetEdit->minimumSizeHint().width() * 3);
aoOffsetEdit->setValidator(new QDoubleValidator(aoOffsetEdit));
offsetLayout->addWidget(aoOffsetEdit, 1, 1);
aoOffsetUnits = new QLabel;
aoOffsetUnits->setText("---");
offsetLayout->addWidget(aoOffsetUnits, 1, 2, Qt::AlignCenter);
ampModeGroupLayout->addLayout(offsetLayout, 0, 0);
// add little bit of space betwen offsets and buttons
ampModeGroupLayout->addItem(
new QSpacerItem(0, 10, QSizePolicy::Expanding, QSizePolicy::Minimum),
2,
0);
// add probe gain combobox
auto* probeGainLayout = new QGridLayout;
auto* probeGainLabel = new QLabel("Probe Gain:");
probeGainComboBox = new AMAmpComboBox;
probeGainComboBox->insertItem(0, QString::fromUtf8("Low (10 MΩ)"));
probeGainComboBox->insertItem(1, QString::fromUtf8("High (10 GΩ)"));
probeGainLayout->addWidget(probeGainLabel, 0, 0);
probeGainLayout->addWidget(probeGainComboBox, 0, 1);
ampModeGroupLayout->addLayout(probeGainLayout, 3, 0);
// add little bit of space betwen offsets and buttons
ampModeGroupLayout->addItem(
new QSpacerItem(0, 10, QSizePolicy::Expanding, QSizePolicy::Minimum),
4,
0);
// make the buttons
ampButtonGroup = new QButtonGroup;
vclampButton = new QRadioButton("VClamp");
ampButtonGroup->addButton(vclampButton, VCLAMP);
izeroButton = new QRadioButton("I = 0");
ampButtonGroup->addButton(izeroButton, IEQ0);
iclampButton = new QRadioButton("IClamp");
ampButtonGroup->addButton(iclampButton, ICLAMP);
vcompButton = new QRadioButton("VComp");
ampButtonGroup->addButton(vcompButton, VCOMP);
vtestButton = new QRadioButton("VTest");
ampButtonGroup->addButton(vtestButton, VTEST);
iresistButton = new QRadioButton("IResist");
ampButtonGroup->addButton(iresistButton, IRESIST);
ifollowButton = new QRadioButton("IFollow");
ampButtonGroup->addButton(ifollowButton, IFOLLOW);
auto* ampButtonGroupLayout = new QGridLayout;
ampButtonGroupLayout->addWidget(vclampButton, 0, 0);
ampButtonGroupLayout->addWidget(izeroButton, 0, 1);
ampButtonGroupLayout->addWidget(iclampButton, 1, 0);
ampButtonGroupLayout->addWidget(vcompButton, 1, 1);
ampButtonGroupLayout->addWidget(vtestButton, 2, 0);
ampButtonGroupLayout->addWidget(iresistButton, 2, 1);
ampButtonGroupLayout->addWidget(ifollowButton, 3, 0);
// We add our own set daq button
auto* setDaqButton = new QPushButton("Set DAQ");
ampModeGroupLayout->addLayout(ampButtonGroupLayout, 5, 0);
// add widgets to custom layout
widget_layout->addWidget(ioGroupBox);
widget_layout->addWidget(ampModeGroupBox);
widget_layout->addWidget(setDaqButton);
setLayout(widget_layout);
// connect the widgets to the signals
QObject::connect(
ampButtonGroup, SIGNAL(buttonPressed(int)), this, SLOT(updateMode(int)));
QObject::connect(ampButtonGroup,
&QButtonGroup::idClicked,
this,
&am_amp2400::Panel::updateOffset);
QObject::connect(inputBox,
QOverload<int>::of(&AMAmpSpinBox::valueChanged),
this,
&am_amp2400::Panel::updateInputChannel);
QObject::connect(outputBox,
QOverload<int>::of(&AMAmpSpinBox::valueChanged),
this,
&am_amp2400::Panel::updateOutputChannel);
QObject::connect(aiOffsetEdit,
&AMAmpLineEdit::textEdited,
this,
&am_amp2400::Panel::setAIOffset);
QObject::connect(aoOffsetEdit,
&AMAmpLineEdit::textEdited,
this,
&am_amp2400::Panel::setAOOffset);
QObject::connect(probeGainComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
&am_amp2400::Panel::setProbeGain);
QObject::connect(
setDaqButton, &QPushButton::clicked, this, &am_amp2400::Panel::modify);
}
void am_amp2400::Panel::setProbeGain(int index)
{
if (index > 2) {
ERROR_MSG(
"am_amp2400::Panel::setProbeGain : Invalid index passed. Check amp "
"implementation");
return;
}
mode = amp_mode(index);
}
void am_amp2400::Panel::updateDAQ()
{
if (devicesComboBox->count() == 0) {
ERROR_MSG("Unable to update device. No devices were found!");
return;
}
auto* current_device = devicesComboBox->currentData().value<DAQ::Device*>();
if (current_device == nullptr) {
ERROR_MSG(
"Device selected is nullptr. Aborting submission! Please email "
"info@rtxi.org for help.");
}
switch (this->mode) {
case amp_mode::VCLAMP: // VClamp
current_device->setAnalogRange(DAQ::ChannelType::AI, input_channel, 0);
current_device->setAnalogGain(
DAQ::ChannelType::AI, input_channel, vclamp_ai_gain);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AI, input_channel, ai_offset);
current_device->setAnalogGain(
DAQ::ChannelType::AO, output_channel, vclamp_ao_gain);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AO, output_channel, ao_offset);
current_device->writeinput(digital_line_0, 0.0);
current_device->writeinput(digital_line_1, 5.0);
current_device->writeinput(digital_line_2, 0.0);
break;
case amp_mode::IEQ0: // I = 0
current_device->setAnalogRange(DAQ::ChannelType::AI, input_channel, 3);
current_device->setAnalogGain(
DAQ::ChannelType::AI, input_channel, izero_ai_gain);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AI, input_channel, ai_offset);
current_device->setAnalogGain(DAQ::ChannelType::AO,
output_channel,
izero_ao_gain * probe_gain_factor);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AO, output_channel, ao_offset);
current_device->writeinput(digital_line_0, 5.0);
current_device->writeinput(digital_line_1, 5.0);
current_device->writeinput(digital_line_2, 0.0);
break;
case amp_mode::ICLAMP: // IClamp
current_device->setAnalogRange(DAQ::ChannelType::AI, input_channel, 3);
current_device->setAnalogGain(
DAQ::ChannelType::AI, input_channel, iclamp_ai_gain);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AI, input_channel, ai_offset);
current_device->setAnalogGain(
DAQ::ChannelType::AO, output_channel, iclamp_ao_gain);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AO, output_channel, ao_offset);
current_device->writeinput(digital_line_0, 0.0);
current_device->writeinput(digital_line_1, 0.0);
current_device->writeinput(digital_line_2, 5.0);
break;
case amp_mode::VCOMP: // VComp
current_device->setAnalogRange(DAQ::ChannelType::AI, input_channel, 0);
current_device->setAnalogGain(
DAQ::ChannelType::AI, input_channel, vclamp_ai_gain);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AI, input_channel, ai_offset);
current_device->setAnalogGain(
DAQ::ChannelType::AO, output_channel, vclamp_ao_gain);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AO, output_channel, ao_offset);
current_device->writeinput(digital_line_0, 5.0);
current_device->writeinput(digital_line_1, 0.0);
current_device->writeinput(digital_line_2, 0.0);
break;
case amp_mode::VTEST: // VTest
current_device->setAnalogRange(DAQ::ChannelType::AI, input_channel, 0);
current_device->setAnalogGain(
DAQ::ChannelType::AI, input_channel, vclamp_ai_gain);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AI, input_channel, ai_offset);
current_device->setAnalogGain(
DAQ::ChannelType::AO, output_channel, vclamp_ao_gain);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AO, output_channel, ao_offset);
current_device->writeinput(digital_line_0, 0.0);
current_device->writeinput(digital_line_1, 0.0);
current_device->writeinput(digital_line_2, 0.0);
break;
case amp_mode::IRESIST: // IResist
current_device->setAnalogRange(DAQ::ChannelType::AI, input_channel, 3);
current_device->setAnalogGain(
DAQ::ChannelType::AI, input_channel, iclamp_ai_gain);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AI, input_channel, ai_offset);
current_device->setAnalogGain(DAQ::ChannelType::AO,
output_channel,
iclamp_ao_gain * probe_gain_factor);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AO, output_channel, ao_offset);
current_device->writeinput(digital_line_0, 5.0);
current_device->writeinput(digital_line_1, 0.0);
current_device->writeinput(digital_line_2, 5.0);
break;
case amp_mode::IFOLLOW: // IFollow
current_device->setAnalogRange(DAQ::ChannelType::AI, input_channel, 3);
current_device->setAnalogGain(DAQ::ChannelType::AI,
input_channel,
iclamp_ai_gain * probe_gain_factor);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AI, input_channel, ai_offset);
current_device->setAnalogGain(
DAQ::ChannelType::AO, output_channel, iclamp_ao_gain);
current_device->setAnalogZeroOffset(
DAQ::ChannelType::AO, output_channel, ao_offset);
current_device->writeinput(digital_line_0, 0.0);
current_device->writeinput(digital_line_1, 5.0);
current_device->writeinput(digital_line_2, 5.0);
break;
default:
ERROR_MSG(
"ERROR. Something went horribly wrong. The amplifier mode "
"is set to an unknown value");
break;
}
};
void am_amp2400::Panel::modify()
{
input_channel = inputBox->text().toInt();
output_channel = outputBox->text().toInt();
digital_line_0 = bit1Box->text().toInt();
digital_line_1 = bit2Box->text().toInt();
digital_line_2 = bit4Box->text().toInt();
ampButtonGroup->button(mode)->setStyleSheet("QRadioButton { font: normal; }");
ampButtonGroup->button(mode)->setStyleSheet("QRadioButton { font: bold;}");
const auto probe_gain = probe_gain_t(probeGainComboBox->currentIndex());
switch (probe_gain) {
case HIGH:
probe_gain_factor = 1; //.10;
break;
case LOW:
probe_gain_factor = 10; // 1;
break;
default:
ERROR_MSG("ERROR: default called for probe_gain in update(MODIFY)");
break;
}
ai_offset = this->aiOffsetEdit->text().toDouble();
ao_offset = this->aoOffsetEdit->text().toDouble();
updateDAQ();
// blacken the GUI to reflect that changes have been saved to
inputBox->blacken();
outputBox->blacken();
aiOffsetEdit->blacken();
aoOffsetEdit->blacken();
probeGainComboBox->blacken();
bit1Box->blacken();
bit2Box->blacken();
bit4Box->blacken();
}
void am_amp2400::Panel::setAIOffset(const QString& offset)
{
ai_offset = offset.toDouble();
}
void am_amp2400::Panel::setAOOffset(const QString& offset)
{
ao_offset = offset.toDouble();
}
void am_amp2400::Panel::updateOffset(int new_mode)
{
double scaled_ai_offset = ai_offset;
double scaled_ao_offset = ao_offset;
switch (mode) {
case VCLAMP: // VClamp
case VCOMP: // VComp
case VTEST: // VTest
scaled_ai_offset = scaled_ai_offset * vclamp_ai_gain;
scaled_ao_offset = scaled_ao_offset * vclamp_ao_gain;
break;
case IEQ0: // I = 0
scaled_ai_offset = scaled_ai_offset * izero_ai_gain;
scaled_ao_offset = scaled_ao_offset * izero_ao_gain;
break;
case ICLAMP: // IClamp
case IRESIST: // IResist
case IFOLLOW: // IFollow
scaled_ai_offset = scaled_ai_offset * iclamp_ai_gain;
scaled_ao_offset = scaled_ao_offset * iclamp_ao_gain;
break;
default:
ERROR_MSG(
"ERROR. Something went horribly wrong.\n The amplifier mode "
"is set to an unknown value");
break;
}
switch (new_mode) {
case VCLAMP: // VClamp
case VCOMP: // VComp
case VTEST: // VTest
scaled_ai_offset = scaled_ai_offset / vclamp_ai_gain;
scaled_ao_offset = scaled_ao_offset / vclamp_ao_gain;
aiOffsetUnits->setText("1 mV/pA");
aoOffsetUnits->setText("20 mV/V");
break;
case IEQ0: // I = 0
scaled_ai_offset = scaled_ai_offset / izero_ai_gain;
scaled_ao_offset = scaled_ao_offset / izero_ao_gain;
aiOffsetUnits->setText("1 V/V");
aoOffsetUnits->setText("---");
break;
case IRESIST: // IResist
case IFOLLOW: // IFollow
case ICLAMP: // IClamp
scaled_ai_offset = scaled_ai_offset / iclamp_ai_gain;
scaled_ao_offset = scaled_ao_offset / iclamp_ao_gain;
aiOffsetUnits->setText("1 V/V");
aoOffsetUnits->setText("2 nA/V");
break;
default:
ERROR_MSG(
"ERROR. Something went horribly wrong.\n The amplifier mode "
"is set to an unknown value");
break;
}
aiOffsetEdit->setText(QString::number(scaled_ai_offset));
aiOffsetEdit->setModified(true);
aoOffsetEdit->setText(QString::number(scaled_ao_offset));
aoOffsetEdit->setModified(true);
}
void am_amp2400::Panel::updateMode(int value)
{
mode = amp_mode(value);
}
void am_amp2400::Panel::updateOutputChannel(int value)
{
output_channel = value;
}
void am_amp2400::Panel::updateInputChannel(int value)
{
input_channel = value;
}
/*
void am_amp2400::Panel::findZeroOffset()
{
findZeroButton->setEnabled(false);
iclampButton->setEnabled(false);
vclampButton->setEnabled(false);
izeroButton->setEnabled(false);
vcompButton->setEnabled(false);
vtestButton->setEnabled(false);
iresistButton->setEnabled(false);
ifollowButton->setEnabled(false);
pause(false);
}
*/
// It is not clear why this was created. It is not neccessary to calibrate
// the output signal with the new drivers since it is forcebly set when you
// write to AO. Analog inputs may be calibrated, but the input analog
// calibration in previous iterations of this plugin did not actually work! It
// seems redundant and unused feature. If the user wishes to automatically
// calibrate input analog channels then perhaps we can implement it here, but
// for now this is disabled.
/*
void am_amp2400::Panel::calculateOffset()
{
if (!data_acquired) {
std::cout << "Not done yet... " << signal_count << std::endl;
return;
}
checkZeroCalc->stop();
pause(true);
switch (channel) {
case AI:
zero_offset = zero_signal.mean();
std::cout << "AI Calc. Offst. = " << zero_offset * izero_ai_gain
<< std::endl;
std::cout << "AI Curr. Offst. = " << ai_offset << std::endl;
std::cout << "AI Total Offst. = "
<< zero_offset * izero_ai_gain + ai_offset << std::endl;
zero_signal.clear();
aiOffsetEdit->setText(
QString::number(zero_offset * izero_ai_gain + ai_offset));
aiOffsetEdit->redden();
parameter["AI Offset"].edit->setText(
QString::number(zero_offset * izero_ai_gain + ai_offset));
parameter["AI Offset"].edit->setModified(true);
channel = AO;
data_acquired = false;
zero_offset = 0;
checkZeroCalc->start();
pause(false);
break;
case AO:
zero_offset = zero_signal.mean();
std::cout << "AO Calc. Offst. = " << zero_offset << std::endl;
std::cout << "AO Curr. Offst. = " << ao_offset << std::endl;
std::cout << "AO Total Offst. = " << ao_offset + zero_offset <<
std::endl
<< std::endl;
zero_signal.clear();
aoOffsetEdit->setText(QString::number(ao_offset + zero_offset));
aoOffsetEdit->redden();
parameter["AO Offset"].edit->setText(
QString::number(zero_offset + ao_offset));
parameter["AO Offset"].edit->setModified(true);
findZeroButton->setEnabled(true);
iclampButton->setEnabled(true);
vclampButton->setEnabled(true);
izeroButton->setEnabled(true);
vcompButton->setEnabled(true);
vtestButton->setEnabled(true);
iresistButton->setEnabled(true);
ifollowButton->setEnabled(true);
modifyButton->setEnabled(true);
channel = NA;
zero_offset = 0;
break;
case NA:
std::cout << "Case NA isn't supposed to be called." << std::endl;
break;
default:
std::cout << "ERROR: default case called." << std::endl;
break;
}
}*/
std::unique_ptr<Widgets::Plugin> createRTXIPlugin(Event::Manager* ev_manager)
{
return std::make_unique<am_amp2400::Plugin>(ev_manager);
}
Widgets::Panel* createRTXIPanel(QMainWindow* main_window,
Event::Manager* ev_manager)
{
return new am_amp2400::Panel(main_window, ev_manager);
}
std::unique_ptr<Widgets::Component> createRTXIComponent(
Widgets::Plugin* host_plugin)
{
return nullptr;
}
Widgets::FactoryMethods fact;
extern "C"
{
Widgets::FactoryMethods* getFactories()
{
fact.createPanel = &createRTXIPanel;
fact.createComponent = &createRTXIComponent;
fact.createPlugin = &createRTXIPlugin;
return &fact;
}
};
//////////// END //////////////////////