-
Notifications
You must be signed in to change notification settings - Fork 0
/
fsConfigureAOut.cpp
executable file
·616 lines (488 loc) · 21.9 KB
/
fsConfigureAOut.cpp
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
#include "fsGUI.h"
#include "laser.h"
AOutConfigTab::AOutConfigTab (QWidget *parent)
: QWidget(parent)
{
QString s;
QGridLayout *layout = new QGridLayout;
QLabel *explanation = new QLabel(
"Configuration parameters for Analog Outputs " \
"<br>These parameters are used for "
"<b>either</b> <i>Output-only Experiments</i> or "\
"<i>Real-time Feedback Experiments.</i>");
//explanation->setAlignment(Qt::AlignHCenter);
explanation->setWordWrap(true);
explanation->setIndent(30);
layout->addWidget(explanation,0,0,1,2);
activeAOut = 0;
aOut1Button = new QPushButton("AOut 1");
layout->addWidget(aOut1Button,1,0,Qt::AlignRight | Qt::AlignVCenter);
aOut1Button->setCheckable(true);
aOut1Button->setChecked(false);
aOut1Button->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Maximum);
aOut1Button->setStyleSheet("QPushButton::checked{color: green;}");
connect(aOut1Button, SIGNAL(clicked(bool)), this, SLOT(selectAOut(void)));
aOut1Config = new AOutConfigureWidget(this);
aOut1Config->aOutPulseCmd.aout = 0;
connect(aOut1Config, SIGNAL(aOutModeChangedSignal(void)), this,
SLOT(aOutModeChanged(void)));
layout->addWidget(aOut1Config,1,1,Qt::AlignLeft | Qt::AlignVCenter);
aOut2Button = new QPushButton("AOut 2");
layout->addWidget(aOut2Button,2,0,Qt::AlignRight | Qt::AlignVCenter);
aOut2Button->setCheckable(true);
aOut2Button->setChecked(false);
aOut2Button->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Maximum);
aOut2Button->setStyleSheet("QPushButton::checked{color: green;}");
//aOut2Button->setEnabled(false);
connect(aOut2Button, SIGNAL(clicked(bool)), this, SLOT(selectAOut(void)));
aOut2Config = new AOutConfigureWidget(this);
aOut2Config->aOutPulseCmd.aout = 1;
connect(aOut2Config, SIGNAL(aOutModeChangedSignal(void)), this,
SLOT(aOutModeChanged(void)));
layout->addWidget(aOut2Config,2,1,Qt::AlignLeft | Qt::AlignVCenter);
QFont font;
font.setPointSize(12);
font.setBold(true);
aOut1Button->setFont(font);
aOut2Button->setFont(font);
layout->setColumnStretch(1,1);
setLayout(layout);
setActiveAOut(0);
}
void AOutConfigTab::selectAOut(void)
{
aOut1Config->setEnabled(aOut1Button->isChecked());
aOut2Config->setEnabled(aOut2Button->isChecked());
emit activeAOutChanged(aOut1Button->isChecked() +
2*((int)aOut2Button->isChecked()), aOut1Config->aOutPulseCmd.aout_mode,
aOut2Config->aOutPulseCmd.aout_mode);
qDebug("Emitting activeAOutChanged signal");
return;
}
void AOutConfigTab::setActiveAOut(int which)
{
qDebug("Received setActiveAOut signal %d",which);
activeAOut = which;
aOut1Button->setChecked(which & 0x01);
aOut2Button->setChecked(which & 0x02);
selectAOut();
return;
}
void AOutConfigTab::aOutModeChanged(void)
{
/* we need to send the signal out to the tabs to tell them there has been a change
* */
selectAOut();
return;
}
void AOutConfigTab::saveToXML(QDomDocument &doc, QDomElement &rootNode) {
QDomElement aConf = doc.createElement("aOutConfiguration");
rootNode.appendChild(aConf);
aConf.setAttribute("aOut1Checked",aOut1Button->isChecked());
aConf.setAttribute("aOut2Checked",aOut2Button->isChecked());
aOut1Config->saveToXML(doc, aConf);
aOut2Config->saveToXML(doc, aConf);
}
int AOutConfigTab::loadFromXML(QDomNode &aOutNode) {
int error;
aOut1Button->setChecked((bool) aOutNode.toElement().attribute("aOut1Checked").toInt());
aOut2Button->setChecked((bool) aOutNode.toElement().attribute("aOut2Checked").toInt());
QDomNodeList nList = aOutNode.childNodes();
QDomNode n = nList.at(0);
QDomElement nt = n.toElement();
aOut1Config->loadFromXML(nt);
n = nList.at(1);
nt = n.toElement();
aOut2Config->loadFromXML(nt);
return 1;
}
AOutConfigureWidget::AOutConfigureWidget(QWidget *parent)
: QWidget(parent)
{
QGridLayout *layout = new QGridLayout;
aOutRangeSelectBox = new QComboBox();
aOutRangeSelectBox->addItem("Mambo 594nm Laser");
aOutRangeSelectBox->addItem("Adjustable Range");
layout->addWidget(aOutRangeSelectBox, 0, 0, 1, 4, Qt::AlignBottom);
connect(aOutRangeSelectBox, SIGNAL(currentIndexChanged(int)), this,
SLOT(setAOutRange(int)));
layout->addWidget(new QLabel("Min."), 1, 0, 1, 1, Qt::AlignVCenter);
aOutRangeMinSpinBox = new QDoubleSpinBox();
aOutRangeMinSpinBox->setRange(0,1);
aOutRangeMinSpinBox->setSingleStep(0.01);
aOutRangeMinSpinBox->setDecimals(3);
aOutRangeMinSpinBox->setSuffix(" Volts");
layout->addWidget(aOutRangeMinSpinBox, 1, 1, 1, 1, Qt::AlignVCenter);
connect(aOutRangeMinSpinBox, SIGNAL(valueChanged(double)), this, SLOT(updateAOutPulseCmd(void)));
layout->addWidget(new QLabel("Max"), 1, 2, 1, 1, Qt::AlignVCenter);
aOutRangeMaxSpinBox = new QDoubleSpinBox();
aOutRangeMaxSpinBox->setRange(0,1);
aOutRangeMaxSpinBox->setSingleStep(0.01);
aOutRangeMaxSpinBox->setDecimals(3);
aOutRangeMaxSpinBox->setSuffix(" Volts");
layout->addWidget(aOutRangeMaxSpinBox, 1, 3, 1, 1, Qt::AlignVCenter);
connect(aOutRangeMinSpinBox, SIGNAL(valueChanged(double)), this, SLOT(updateAOutPulseCmd(void)));
layout->addWidget(new QLabel("Trigger Bit"), 2, 0, 1, 1, Qt::AlignTop);
aOutTriggerBitSpinBox = new QSpinBox();
aOutTriggerBitSpinBox->setRange(0,63);
layout->addWidget(aOutTriggerBitSpinBox, 2, 1, 1, 1, Qt::AlignTop);
connect(aOutTriggerBitSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateAOutPulseCmd(void)));
aOutModeComboBox = new QComboBox();
aOutModeComboBox->addItem("No Output");
aOutModeComboBox->addItem("Continuous");
aOutModeComboBox->addItem("Pulse");
aOutModeComboBox->addItem("Waveform");
layout->addWidget(aOutModeComboBox, 0, 4, 1, 1, Qt::AlignBottom);
connect(aOutModeComboBox, SIGNAL(currentIndexChanged(int)), this,
SLOT(setAOutMode(int)));
aOutContinuousMode = new AOutContinuousMode(this);
connect(aOutContinuousMode->contPercentSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateAOutPulseCmd(void)));
aOutPulseMode = new AOutPulseMode(this);
connect(aOutPulseMode, SIGNAL(aOutPulseCmdChanged(void)), this, SLOT(updateAOutPulseCmd(void)));
aOutWaveMode = new AOutWaveMode(this);
connect(aOutWaveMode, SIGNAL(aOutWaveChanged(void)), this,
SLOT(updateAOutPulseCmd(void)));
aOutModeStack = new QStackedWidget;
QLabel *noMode = new QLabel("No Output");
aOutModeStack->addWidget(noMode);
aOutModeStack->addWidget(aOutContinuousMode);
aOutModeStack->addWidget(aOutPulseMode);
aOutModeStack->addWidget(aOutWaveMode);
layout->addWidget(aOutModeStack, 0, 5, 3, 1, Qt::AlignVCenter);
setLayout(layout);
aOutRangeSelectBox->setCurrentIndex(0);
setAOutRange(0);
}
void AOutConfigureWidget::setAOutMode(int index)
{
int mode = 0;
aOutModeStack->setCurrentIndex(index);
fprintf(stderr, "index = %d\n", index);
switch (index) {
case 0:
mode = 0;
break;
case 1:
mode = FS_AO_MODE_CONTINUOUS;
break;
case 2:
mode = FS_AO_MODE_PULSE;
break;
case 3:
mode = FS_AO_MODE_WAVE;
break;
}
aOutPulseCmd.aout_mode = mode;
emit aOutModeChangedSignal();
fprintf(stderr, "aOutMode = %d, %d\n", mode, FS_AO_MODE_CONTINUOUS);
}
void AOutConfigureWidget::setAOutRange(int index)
{
aOutRangeMinSpinBox->setEnabled(false);
aOutRangeMaxSpinBox->setEnabled(false);
switch (index) {
case 0:
// Mambo 594 nm laser with AOM
aOutRangeMinSpinBox->setValue(MAMBO_594_MIN_VOLTAGE);
aOutRangeMaxSpinBox->setValue(MAMBO_594_MAX_VOLTAGE);
break;
case 1:
// full range
aOutRangeMinSpinBox->setValue(0);
aOutRangeMaxSpinBox->setValue(1);
aOutRangeMinSpinBox->setEnabled(true);
aOutRangeMaxSpinBox->setEnabled(true);
break;
}
}
void AOutConfigureWidget::updateAOutPulseCmd(void)
{
float slope;
unsigned short minlevel, maxlevel, deltalevel;
int i;
/* go through all the objects and update the pulse command */
// we assume statemachine 0; we probably want to make this user selectable
aOutPulseCmd.statemachine = 0;
aOutPulseCmd.digital_only = false;
aOutPulseCmd.pin1 = aOutTriggerBitSpinBox->value();
aOutPulseCmd.minv = aOutRangeMinSpinBox->value();
aOutPulseCmd.maxv = aOutRangeMaxSpinBox->value();
aOutPulseCmd.cont_percent = aOutContinuousMode->contPercentSpinBox->value();
aOutPulseCmd.pulse_percent = aOutPulseMode->pulsePercentSpinBox->value();
aOutPulseCmd.pulse_width = aOutPulseMode->pulseLengthSpinBox->value()*10; // conver to 0.1 ms ticks
aOutPulseCmd.inter_pulse_delay = aOutPulseMode->sequencePeriodSpinBox->value()*10 - aOutPulseCmd.pulse_width;
aOutPulseCmd.n_pulses = aOutPulseMode->nPulsesSpinBox->value();
/* go through all the objects and update the pulse command */
// we assume statemachine 0; we probably want to make this user selectable
aOutPulseCmd.statemachine = 0;
aOutPulseCmd.digital_only = false;
aOutPulseCmd.pin1 = aOutTriggerBitSpinBox->value();
aOutPulseCmd.minv = aOutRangeMinSpinBox->value();
aOutPulseCmd.maxv = aOutRangeMaxSpinBox->value();
aOutPulseCmd.wave_percent = aOutWaveMode->maxPercentSpinBox->value();
aOutPulseCmd.arbinfo.aout = aOutPulseCmd.aout;
aOutPulseCmd.arbinfo.continuous = aOutWaveMode->continuousButton->isChecked();
aOutPulseCmd.arbinfo.trigger_pin = aOutPulseCmd.pin1;
/* create the waveform */
minlevel = (unsigned short) (aOutPulseCmd.minv * USHRT_MAX);
deltalevel = (unsigned short) (((float) ((aOutPulseCmd.maxv -
aOutPulseCmd.minv) * ((float) aOutPulseCmd.wave_percent) / 100.0)) *
USHRT_MAX);
maxlevel = minlevel + deltalevel;
if (aOutWaveMode->rampButton->isChecked()) {
/* convert the length in ms to samples */
aOutPulseCmd.arbinfo.len =
aOutWaveMode->lengthSpinBox->value() * SAMP_TO_TIMESTAMP *
10;
/* calculate the pulse width for this signal in timestamp
* units */
aOutPulseCmd.pulse_width = aOutPulseCmd.arbinfo.len /
SAMP_TO_TIMESTAMP;
slope = (float) (maxlevel - minlevel) / aOutPulseCmd.arbinfo.len;
/* create a ramp */
for (i = 0; i < aOutPulseCmd.arbinfo.len; i++) {
aOutPulseCmd.arbinfo.wavefm[i] = (unsigned short) (minlevel + i * slope);
}
// set to zero to reset ramp
aOutPulseCmd.arbinfo.wavefm[i] = minlevel;
aOutPulseCmd.arbinfo.len++;
}
else if (aOutWaveMode->sineButton->isChecked()) {
/* convert the length in ms to samples */
aOutPulseCmd.arbinfo.len = (unsigned short) (aOutWaveMode->lengthSpinBox->value()) * SAMP_TO_TIMESTAMP * 10;
/* calculate the pulse width for this signal in timestamp
* units */
aOutPulseCmd.pulse_width = aOutPulseCmd.arbinfo.len /
SAMP_TO_TIMESTAMP;
fprintf(stderr, "pulse_width = %d timestamps\n",
aOutPulseCmd.arbinfo.len);
/* create a sine wave that begins at a phase of -pi/2 to start at the minimum level */
for (i = 0; i < aOutPulseCmd.arbinfo.len; i++) {
aOutPulseCmd.arbinfo.wavefm[i] = minlevel + (unsigned
short) ((1 + sin(TWOPI * 1.0 / ((float)
aOutPulseCmd.arbinfo.len) * i - PI / 2)) / 2.0 * (float) deltalevel);
}
}
}
void AOutConfigureWidget::saveToXML(QDomDocument &doc, QDomElement &aConf) {
QDomElement nt = doc.createElement("singleAOutConfiguration");
nt.setAttribute("rangeSelected", aOutRangeSelectBox->currentIndex());
nt.setAttribute("rangeMinValue", aOutRangeMinSpinBox->value());
nt.setAttribute("rangeMaxValue", aOutRangeMaxSpinBox->value());
nt.setAttribute("modeSelected", aOutModeComboBox->currentIndex());
// wave mode specific values
nt.setAttribute("rampSelected", aOutWaveMode->rampButton->isChecked());
nt.setAttribute("sineSelected", aOutWaveMode->sineButton->isChecked());
nt.setAttribute("continuous", aOutWaveMode->continuousButton->isChecked());
nt.setAttribute("maxPercent", aOutWaveMode->maxPercentSpinBox->value());
nt.setAttribute("waveLength", aOutWaveMode->lengthSpinBox->value());
// continuous mode specific values
nt.setAttribute("contPercent", aOutContinuousMode->contPercentSpinBox->value());
// pulse mode specific values
nt.setAttribute("pulseLength", aOutPulseMode->pulseLengthSpinBox->value());
nt.setAttribute("nPulses", aOutPulseMode->nPulsesSpinBox->value());
nt.setAttribute("sequenceFrequency", aOutPulseMode->sequenceFrequencySpinBox->value());
nt.setAttribute("sequencePeriod", aOutPulseMode->sequencePeriodSpinBox->value());
nt.setAttribute("pulsePercent", aOutPulseMode->pulsePercentSpinBox->value());
aConf.appendChild(nt);
}
int AOutConfigureWidget::loadFromXML(QDomElement &nt) {
aOutRangeSelectBox->setCurrentIndex(nt.attribute("rangeSelected").toInt());
aOutRangeMinSpinBox->setValue(nt.attribute("rangeMinValue").toDouble());
aOutRangeMaxSpinBox->setValue(nt.attribute("rangeMaxValue").toDouble());
aOutModeComboBox->setCurrentIndex(nt.attribute("modeSelected").toInt());
aOutWaveMode->rampButton->setChecked((bool)nt.attribute("rampSelected").toInt());
aOutWaveMode->sineButton->setChecked((bool)nt.attribute("sineSelected").toInt());
aOutWaveMode->continuousButton->setChecked((bool)nt.attribute("continuous").toInt());
aOutWaveMode->maxPercentSpinBox->setValue(nt.attribute("maxPercent").toInt());
aOutWaveMode->lengthSpinBox->setValue(nt.attribute("waveLength").toInt());
aOutContinuousMode->contPercentSpinBox->setValue(nt.attribute("contPercent").toInt());
aOutPulseMode->pulseLengthSpinBox->setValue(nt.attribute("pulseLength").toInt());
aOutPulseMode->nPulsesSpinBox->setValue(nt.attribute("nPulses").toInt());
aOutPulseMode->sequenceFrequencySpinBox->setValue(nt.attribute("sequenceFrequency").toDouble());
aOutPulseMode->sequencePeriodSpinBox->setValue(nt.attribute("sequencePeriod").toDouble());
aOutPulseMode->pulsePercentSpinBox->setValue(nt.attribute("pulsePercent").toInt());
// ideally we'd do more error checking above
return 1;
}
AOutContinuousMode::AOutContinuousMode(QWidget *parent) : QWidget(parent)
{
QGridLayout *layout = new QGridLayout;
layout->addWidget(new QLabel("Continuous Level: "), 0, 0, 1, 1, Qt::AlignRight);
contPercentSpinBox = new QSpinBox();
contPercentSpinBox->setRange(0,100);
contPercentSpinBox->setSuffix(" Percent");
contPercentSpinBox->setValue(0);
layout->addWidget(contPercentSpinBox, 0, 1, 1, 1);
setLayout(layout);
qDebug("set up continuous mode");
}
AOutPulseMode::AOutPulseMode(QWidget *parent) : QWidget(parent)
{
aOutPulseCmd.statemachine = 0;
aOutPulseCmd.pre_delay = 0;
aOutPulseCmd.pulse_width = 1; // default value - should set this below?
aOutPulseCmd.pulse_percent = 0; // default value - should set this below?
aOutPulseCmd.inter_pulse_delay = 1249;
aOutPulseCmd.n_pulses = 1;
aOutPulseCmd.is_biphasic = 0;
aOutPulseCmd.pin1 = 1;
aOutPulseCmd.pin2 = 1;
aOutPulseCmd.n_repeats = 0;
aOutPulseCmd.inter_frame_delay = 0;
QGroupBox *groupBox = new QGroupBox();
pulseLengthSpinBox = new QDoubleSpinBox();
pulseLengthSpinBox->setSuffix(" ms");
pulseLengthSpinBox->setAlignment(Qt::AlignRight);
pulseLengthSpinBox->setDecimals(1);
pulseLengthSpinBox->setRange(0.1,5000);
pulseLengthSpinBox->setToolTip("Length in milliseconds of each pulse in pulse sequence.");
connect(pulseLengthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(pulseChanged(void)));
pulsePercentSpinBox = new QSpinBox();
pulsePercentSpinBox->setSuffix(" percent");
pulsePercentSpinBox->setAlignment(Qt::AlignRight);
pulsePercentSpinBox->setRange(0,100);
pulsePercentSpinBox->setToolTip("Percent of maximum for pulse amplitude.");
connect(pulsePercentSpinBox, SIGNAL(valueChanged(int)), this, SLOT(pulseChanged(void)));
nPulsesSpinBox = new QSpinBox();
nPulsesSpinBox->setRange(1,10);
nPulsesSpinBox->setAlignment(Qt::AlignRight);
nPulsesSpinBox->setToolTip("Number of pulses in pulse sequence.");
connect(nPulsesSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ablePulseSequence(void)));
sequencePeriodSpinBox = new QDoubleSpinBox();
sequencePeriodSpinBox->setAlignment(Qt::AlignRight);
sequencePeriodSpinBox->setSuffix(" ms");
sequencePeriodSpinBox->setRange(10,10000);
sequencePeriodSpinBox->setToolTip("Period of pulses in pulse sequence.");
connect(sequencePeriodSpinBox, SIGNAL(valueChanged(double)), this, SLOT(periodChanged(void)));
sequenceFrequencySpinBox = new QDoubleSpinBox();
sequenceFrequencySpinBox->setAlignment(Qt::AlignRight);
sequenceFrequencySpinBox->setRange(0.1,100);
sequenceFrequencySpinBox->setSuffix(" Hz");
sequenceFrequencySpinBox->setToolTip("Frequency of pulses in pulse sequence.");
connect(sequenceFrequencySpinBox, SIGNAL(valueChanged(double)), this, SLOT(frequencyChanged(void)));
QLabel *pulseLengthGraphic = new QLabel;
pulseLengthGraphic->setPixmap(QPixmap(":/images/pulselength.png"));
pulseLengthGraphic->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
QGridLayout *parametersLayout = new QGridLayout;
QLabel *nPulsesGraphic = new QLabel;
nPulsesGraphic->setPixmap(QPixmap(":/images/npulses.png"));
nPulsesGraphic->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
parametersLayout->addWidget(new QLabel("Pulse Length"), 0, 0,
Qt::AlignRight | Qt::AlignVCenter);
parametersLayout->addWidget(pulseLengthSpinBox, 0, 1);
parametersLayout->addWidget(pulseLengthGraphic, 0, 2);
parametersLayout->setRowMinimumHeight(1, 5);
parametersLayout->addWidget(new QLabel("Pulse amplitude"), 1, 0,
Qt::AlignRight | Qt::AlignVCenter);
parametersLayout->addWidget(pulsePercentSpinBox, 1, 1);
parametersLayout->addWidget(new QLabel("# of Pulses"),2,0,
Qt::AlignRight | Qt::AlignVCenter);
parametersLayout->addWidget(nPulsesSpinBox, 2, 1);
parametersLayout->addWidget(nPulsesGraphic, 2, 2);
/* For multi-pulse sequences, control frequency or period of
* pulses in train. */
multiPulseGroup = new QGroupBox;
QGridLayout *multiPulseLayout = new QGridLayout;
multiPulseLayout->addWidget(new QLabel("Period"),0,0,
Qt::AlignRight | Qt::AlignVCenter);
multiPulseLayout->addWidget(sequencePeriodSpinBox, 0, 1);
multiPulseLayout->addWidget(new QLabel("Frequency"),1,0,
Qt::AlignRight | Qt::AlignVCenter);
multiPulseLayout->addWidget(sequenceFrequencySpinBox,1,1);
QLabel *pulsePeriodGraphic = new QLabel;
pulsePeriodGraphic->setPixmap(QPixmap(":/images/period.png"));
multiPulseLayout->addWidget(pulsePeriodGraphic,0,2,2,1, Qt::AlignCenter);
multiPulseGroup->setLayout(multiPulseLayout);
multiPulseGroup->setEnabled(false);
parametersLayout->addWidget(multiPulseGroup,3,0,1,3,Qt::AlignRight);
groupBox->setLayout(parametersLayout);
QGridLayout *layout = new QGridLayout;
layout->addWidget(groupBox,0,0);
setLayout(layout);
// Load defaults
// Update state (number of pulses->period, biphasic->secondary aOut)
}
void AOutPulseMode::pulseChanged(void)
{
emit aOutPulseCmdChanged();
return;
}
void AOutPulseMode::frequencyChanged(void)
{
sequencePeriodSpinBox->blockSignals(true);
sequencePeriodSpinBox->setValue(1000/sequenceFrequencySpinBox->value());
sequencePeriodSpinBox->blockSignals(false);
emit aOutPulseCmdChanged();
return;
}
void AOutPulseMode::periodChanged(void)
{
sequenceFrequencySpinBox->blockSignals(true);
sequenceFrequencySpinBox->setValue(1000/sequencePeriodSpinBox->value());
sequenceFrequencySpinBox->blockSignals(false);
emit aOutPulseCmdChanged();
}
void AOutPulseMode::ablePulseSequence(void)
{
if (nPulsesSpinBox->value() > 1) {
multiPulseGroup->setEnabled(true);
}
else {
multiPulseGroup->setEnabled(false);
}
emit aOutPulseCmdChanged();
}
AOutWaveMode::AOutWaveMode(QWidget *parent) : QWidget(parent)
{
QGridLayout *layout = new QGridLayout;
/* create a button group for the sine & ramp buttons */
QButtonGroup *waveModeButtonGroup = new QButtonGroup();
waveModeButtonGroup->setExclusive(true);
sineButton = new QPushButton("Sine Wave");
sineButton->setCheckable(true);
sineButton->setChecked(false);
sineButton->setStyleSheet("QPushButton::checked{color: green;}");
connect(sineButton, SIGNAL(clicked(bool)), this, SLOT(waveChanged(void)));
waveModeButtonGroup->addButton(sineButton);
layout->addWidget(sineButton, 0, 0,Qt::AlignRight | Qt::AlignVCenter);
rampButton = new QPushButton("Ramp");
rampButton->setCheckable(true);
rampButton->setChecked(false);
rampButton->setStyleSheet("QPushButton::checked{color: green;}");
connect(rampButton, SIGNAL(clicked(bool)), this, SLOT(waveChanged(void)));
waveModeButtonGroup->addButton(rampButton);
layout->addWidget(rampButton, 0, 1,Qt::AlignRight | Qt::AlignVCenter);
layout->addWidget(new QLabel("Maximum Level: "), 1, 0, Qt::AlignRight);
maxPercentSpinBox = new QSpinBox();
maxPercentSpinBox->setAlignment(Qt::AlignRight);
maxPercentSpinBox->setRange(0,100);
maxPercentSpinBox->setValue(0);
maxPercentSpinBox->setSuffix(" Percent");
maxPercentSpinBox->setToolTip("Percentage of maximum for peak of waveform");
layout->addWidget(maxPercentSpinBox, 1, 1, Qt::AlignRight);
connect(maxPercentSpinBox, SIGNAL(valueChanged(int)), this, SLOT(waveChanged(void)));
layout->addWidget(new QLabel("Length/Period: "), 2, 0, Qt::AlignRight);
lengthSpinBox = new QSpinBox();
lengthSpinBox->setAlignment(Qt::AlignRight);
/* FIX */
lengthSpinBox->setRange(0, 20000);
lengthSpinBox->setValue(0);
lengthSpinBox->setSuffix(" ms");
lengthSpinBox->setToolTip("Length in ms of ramp");
layout->addWidget(lengthSpinBox, 2, 1, Qt::AlignRight);
connect(lengthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(waveChanged(void)));
continuousButton = new QPushButton("Continuous");
layout->addWidget(continuousButton, 3, 0,Qt::AlignRight | Qt::AlignVCenter);
continuousButton->setCheckable(true);
continuousButton->setChecked(false);
continuousButton->setStyleSheet("QPushButton::checked{color: green;}");
connect(continuousButton, SIGNAL(toggled(bool)), this, SLOT(waveChanged(void)));
setLayout(layout);
qDebug("set up waveform mode");
}
void AOutWaveMode::waveChanged(void)
{
emit aOutWaveChanged();
return;
}