34 static void findDAQDevice(
DAQ::Device *dev,
void *arg)
42 static void buildDAQDeviceList(
DAQ::Device *dev,
void *arg)
44 QComboBox *deviceList =
static_cast<QComboBox *
>(arg);
45 deviceList->addItem(QString::fromStdString(dev->
getName()));
52 "<p><b>System Control Panel:</b><br>This control panel allows you to configure " 53 "the channels on your DAQ card. RTXI automatically detects the number and types " 54 "of channels that are available. You should set the \"Scale\" of the channel " 55 "to be the inverse of the gain that is applied to the signal through the " 56 "combination of hardware and software that you are using. To acquire data from " 57 "a channel, you must set it to be Active using the toggle button. Any parameter " 58 "settings such as the \"Range\" or \"Scale\" must be set by clicking the \"Apply\" " 59 "button.<br><br> The \"Thread\" tab allows you to set the period for real-time " 60 "execution. You must click \"Apply\" to change this setting and propagate it " 61 "to other user modules such as the Data Recorder. Custom user modules can " 62 "execute special code when the real-time period is changed using the update(PERIOD) " 67 subWindow =
new QMdiSubWindow;
68 subWindow->setWindowIcon(QIcon(
"/usr/local/share/rtxi/RTXI-widget-icon.png"));
69 subWindow->setAttribute(Qt::WA_DeleteOnClose);
70 subWindow->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint |
71 Qt::WindowMinimizeButtonHint);
75 QGridLayout *layout =
new QGridLayout;
78 deviceGroup =
new QGroupBox(tr(
"DAQ Setup"));
79 QGridLayout *deviceLayout =
new QGridLayout;
82 deviceLayout->addWidget(
new QLabel(tr(
"Device:")), 0, 0);
84 deviceList =
new QComboBox;
85 deviceLayout->addWidget(deviceList, 0, 1, 1, 5);
87 QObject::connect(deviceList,SIGNAL(activated(
int)),
this,SLOT(
updateDevice(
void)));
90 deviceLayout->addWidget(
new QLabel(tr(
"Frequency:")), 1, 0);
91 freqEdit =
new QLineEdit;
92 deviceLayout->addWidget(freqEdit, 1, 1);
93 freqEdit->setText(
"1000");
94 QObject::connect(freqEdit,SIGNAL(textChanged(
const QString &)),
this,SLOT(
updatePeriod(
void)));
95 freqUnitList =
new QComboBox;
96 freqUnitList->setFixedWidth(50);
97 freqUnitList->addItem(
" Hz");
98 freqUnitList->addItem(
"kHz");
99 deviceLayout->addWidget(freqUnitList, 1, 2);
100 QObject::connect(freqUnitList,SIGNAL(activated(
int)),
this,SLOT(
updatePeriod(
void)));
103 deviceLayout->addWidget(
new QLabel(tr(
"Period:")), 1, 3);
104 periodEdit =
new QLineEdit;
105 deviceLayout->addWidget(periodEdit, 1, 4);
106 QObject::connect(periodEdit,SIGNAL(textChanged(
const QString &)),
this,SLOT(
updateFreq(
void)));
107 periodUnitList =
new QComboBox;
108 deviceLayout->addWidget(periodUnitList, 1, 5);
109 periodUnitList->setFixedWidth(50);
110 periodUnitList->addItem(
" s");
111 periodUnitList->addItem(
"ms");
112 periodUnitList->addItem(
"us");
113 periodUnitList->addItem(
"ns");
114 QObject::connect(periodUnitList,SIGNAL(activated(
int)),
this,SLOT(
updateFreq(
void)));
118 deviceGroup->setLayout(deviceLayout);
121 analogGroup =
new QGroupBox(tr(
"Analog Channels"));
122 QGridLayout *analogLayout =
new QGridLayout;
125 analogLayout->addWidget(
new QLabel(tr(
"Channel:")), 1, 0);
127 analogSubdeviceList =
new QComboBox;
128 analogSubdeviceList->addItem(
"Input");
129 analogSubdeviceList->addItem(
"Output");
130 QObject::connect(analogSubdeviceList,SIGNAL(activated(
int)),
this,SLOT(
updateDevice(
void)));
131 analogLayout->addWidget(analogSubdeviceList, 1, 1);
133 analogChannelList =
new QComboBox;
134 QObject::connect(analogChannelList,SIGNAL(activated(
int)),
this,SLOT(
display(
void)));
135 analogLayout->addWidget(analogChannelList, 1, 2);
137 analogActiveButton =
new QPushButton(
"Active");
138 analogActiveButton->setCheckable(
true);
139 analogLayout->addWidget(analogActiveButton, 1, 3);
141 analogLayout->addWidget(
new QLabel(tr(
"Range:")), 2, 0, 1, 1);
142 analogRangeList =
new QComboBox;
143 analogLayout->addWidget(analogRangeList, 2, 1, 1, 2);
145 analogReferenceList =
new QComboBox;
146 analogLayout->addWidget(analogReferenceList, 2, 3, 1, 2);
148 analogLayout->addWidget(
new QLabel(tr(
"Scale:")), 3, 0);
149 analogGainEdit =
new QLineEdit;
150 analogGainEdit->setAlignment(Qt::AlignRight);
151 analogLayout->addWidget(analogGainEdit, 3, 1);
153 analogUnitPrefixList =
new QComboBox;
154 analogUnitPrefixList->addItem(
"yotta-");
155 analogUnitPrefixList->addItem(
"zetta-");
156 analogUnitPrefixList->addItem(
"exa-");
157 analogUnitPrefixList->addItem(
"peta-");
158 analogUnitPrefixList->addItem(
"tera-");
159 analogUnitPrefixList->addItem(
"giga-");
160 analogUnitPrefixList->addItem(
"mega-");
161 analogUnitPrefixList->addItem(
"kilo-");
162 analogUnitPrefixList->addItem(
"");
163 analogUnitPrefixList->addItem(
"milli-");
164 analogUnitPrefixList->addItem(
"micro-");
165 analogUnitPrefixList->addItem(
"nano-");
166 analogUnitPrefixList->addItem(
"pico-");
167 analogUnitPrefixList->addItem(
"femto-");
168 analogUnitPrefixList->addItem(
"atto-");
169 analogUnitPrefixList->addItem(
"zepto-");
170 analogUnitPrefixList->addItem(
"yocto-");
171 analogLayout->addWidget(analogUnitPrefixList, 3, 2);
173 analogUnitList =
new QComboBox;
174 analogLayout->addWidget(analogUnitList, 3, 3);
175 analogLayout->addWidget(
new QLabel(tr(
" / Volt")), 3, 4);
177 analogLayout->addWidget(
new QLabel(tr(
"Offset:")), 4, 0);
178 analogZeroOffsetEdit =
new QLineEdit;
179 analogZeroOffsetEdit->setText(
"0");
180 analogZeroOffsetEdit->setAlignment(Qt::AlignRight);
181 analogLayout->addWidget(analogZeroOffsetEdit, 4, 1);
184 analogUnitPrefixList2 =
new QComboBox;
185 analogUnitPrefixList2->addItem(
"yotta-");
186 analogUnitPrefixList2->addItem(
"zetta-");
187 analogUnitPrefixList2->addItem(
"exa-");
188 analogUnitPrefixList2->addItem(
"peta-");
189 analogUnitPrefixList2->addItem(
"tera-");
190 analogUnitPrefixList2->addItem(
"giga-");
191 analogUnitPrefixList2->addItem(
"mega-");
192 analogUnitPrefixList2->addItem(
"kilo-");
193 analogUnitPrefixList2->addItem(
"");
194 analogUnitPrefixList2->addItem(
"milli-");
195 analogUnitPrefixList2->addItem(
"micro-");
196 analogUnitPrefixList2->addItem(
"nano-");
197 analogUnitPrefixList2->addItem(
"pico-");
198 analogUnitPrefixList2->addItem(
"femto-");
199 analogUnitPrefixList2->addItem(
"atto-");
200 analogUnitPrefixList2->addItem(
"zepto-");
201 analogUnitPrefixList2->addItem(
"yocto-");
202 analogLayout->addWidget(analogUnitPrefixList2, 4, 2, 1, 1);
203 analogLayout->addWidget(
new QLabel(tr(
" Volt/Amps")), 4, 3);
205 analogLayout->addWidget(
new QLabel(tr(
"Downsample:")), 5, 0);
206 analogDownsampleList =
new QComboBox;
207 analogDownsampleList->addItem(
"1");
208 analogDownsampleList->addItem(
"2");
209 analogDownsampleList->addItem(
"4");
210 analogDownsampleList->addItem(
"6");
211 analogDownsampleList->addItem(
"8");
212 analogDownsampleList->addItem(
"10");
213 analogLayout->addWidget(analogDownsampleList, 5, 1);
216 analogGroup->setLayout(analogLayout);
219 digitalGroup =
new QGroupBox(tr(
"Digital I/O"));
220 QGridLayout *digitalLayout =
new QGridLayout;
223 digitalLayout->addWidget(
new QLabel(tr(
"Channel:")), 1, 0, 1, 1);
225 digitalSubdeviceList =
new QComboBox;
226 digitalSubdeviceList->addItem(
"I/O");
227 QObject::connect(digitalSubdeviceList,SIGNAL(activated(
int)),
this,SLOT(
updateDevice(
void)));
228 digitalLayout->addWidget(digitalSubdeviceList, 1, 1, 1, 1);
230 digitalChannelList =
new QComboBox;
231 QObject::connect(digitalChannelList,SIGNAL(activated(
int)),
this,SLOT(
display(
void)));
232 digitalLayout->addWidget(digitalChannelList, 1, 2, 1, 1);
234 digitalDirectionList =
new QComboBox;
235 digitalDirectionList->addItem(
"Input");
236 digitalDirectionList->addItem(
"Output");
237 digitalLayout->addWidget(digitalDirectionList, 1, 3, 1, 1);
239 digitalActiveButton =
new QPushButton(
"Active");
240 digitalActiveButton->setCheckable(
true);
241 digitalLayout->addWidget(digitalActiveButton, 1, 4, 1, 1);
244 digitalGroup->setLayout(digitalLayout);
247 buttonGroup =
new QGroupBox;
248 QHBoxLayout *buttonLayout =
new QHBoxLayout;
251 QPushButton *applyButton =
new QPushButton(
"Apply");
252 QObject::connect(applyButton,SIGNAL(released(
void)),
this,SLOT(
apply(
void)));
253 buttonLayout->addWidget(applyButton);
254 QPushButton *cancelButton =
new QPushButton(
"Close");
255 QObject::connect(cancelButton,SIGNAL(released(
void)),subWindow,SLOT(close()));
256 buttonLayout->addWidget(cancelButton);
259 buttonGroup->setLayout(buttonLayout);
262 layout->addWidget(deviceGroup, 1, 0);
263 layout->addWidget(analogGroup, 2, 0);
264 layout->addWidget(digitalGroup, 3, 0);
265 layout->addWidget(buttonGroup, 4, 0);
269 setWindowTitle(
"System Control Panel");
272 subWindow->setWidget(
this);
273 subWindow->setFixedSize(subWindow->minimumSizeHint());
291 struct find_daq_t info = { deviceList->currentIndex(), 0, };
298 DAQ::index_t a_chan = analogChannelList->currentIndex();
300 double a_gain = analogGainEdit->text().toDouble()*pow(10,-3*(analogUnitPrefixList->currentIndex()-8));
301 double a_zerooffset = analogZeroOffsetEdit->text().toDouble()*pow(10,-3*(analogUnitPrefixList2->currentIndex()-8));
306 dev->
setAnalogRange(a_type,a_chan,analogRangeList->currentIndex());
308 dev->
setAnalogUnits(a_type,a_chan,analogUnitList->currentIndex());
309 dev->
setAnalogDownsample(a_type,a_chan,(analogDownsampleList->itemData(analogDownsampleList->currentIndex(),Qt::DisplayRole)).toInt());
312 DAQ::index_t d_chan = digitalChannelList->currentIndex();
323 double period = periodEdit->text().toDouble();
324 period *= pow(10,3*(3-periodUnitList->currentIndex()));
334 struct find_daq_t info = { deviceList->currentIndex(), 0, };
342 analogChannelList->clear();
343 digitalChannelList->clear();
345 type =
static_cast<DAQ::type_t>(analogSubdeviceList->currentIndex());
348 analogChannelList->addItem(QString::number(i));
354 digitalChannelList->addItem(QString::number(i));
373 period = periodEdit->text().toDouble();
374 period *= pow(10,-3*periodUnitList->currentIndex());
383 freqEdit->setText(QString::number(freq));
384 freqUnitList->setCurrentIndex(i);
399 freq = freqEdit->text().toDouble();
400 if(freqUnitList->currentIndex())
405 while(period < .001 && (i < 4))
411 periodEdit->setText(QString::number(period));
412 periodUnitList->setCurrentIndex(i);
421 struct find_daq_t info = {deviceList->currentIndex(), 0, };
430 deviceList->setEnabled(
false);
431 analogSubdeviceList->setEnabled(
false);
432 digitalSubdeviceList->setEnabled(
false);
435 if(!dev || !analogChannelList->count())
437 analogActiveButton->setChecked(
false);
438 analogActiveButton->setEnabled(
false);
439 analogActiveButton->setChecked(
false);
440 analogChannelList->setEnabled(
false);
441 analogRangeList->setEnabled(
false);
442 analogDownsampleList->setEnabled(
false);
443 analogReferenceList->setEnabled(
false);
444 analogGainEdit->setEnabled(
false);
445 analogZeroOffsetEdit->setEnabled(
false);
446 analogUnitPrefixList->setEnabled(
false);
447 analogUnitPrefixList2->setEnabled(
false);
448 analogUnitList->setEnabled(
false);
458 analogDownsampleList->setEnabled(
true);
460 analogDownsampleList->setEnabled(
false);
462 analogActiveButton->setEnabled(
true);
463 analogChannelList->setEnabled(
true);
464 analogRangeList->setEnabled(
true);
465 analogReferenceList->setEnabled(
true);
466 analogGainEdit->setEnabled(
true);
467 analogZeroOffsetEdit->setEnabled(
true);
468 analogUnitPrefixList->setEnabled(
true);
469 analogUnitPrefixList2->setEnabled(
true);
470 analogUnitList->setEnabled(
true);
472 analogRangeList->clear();
475 analogReferenceList->clear();
478 analogUnitList->clear();
485 analogDownsampleList->setCurrentIndex(analogDownsampleList->findData(QVariant::fromValue(dev->
getAnalogDownsample(type,chan)),Qt::DisplayRole));
497 while(((tmp >= 1000)&&(i > 0))||((tmp < 1)&&(i < 16)))
511 analogGainEdit->setText(QString::number(tmp));
513 analogGainEdit->setText(QString::number(-tmp));
516 analogUnitPrefixList->setCurrentIndex(i);
525 while(((tmp >= 1000) && (i > 0)) || ((tmp < 1) && (i < 16)))
539 analogZeroOffsetEdit->setText(QString::number(tmp));
541 analogZeroOffsetEdit->setText(QString::number(-tmp));
544 analogUnitPrefixList2->setCurrentIndex(i);
547 if(!dev || !digitalChannelList->count())
549 digitalActiveButton->setChecked(
false);
550 digitalActiveButton->setEnabled(
false);
551 digitalChannelList->setEnabled(
false);
552 digitalDirectionList->setEnabled(
false);
559 digitalActiveButton->setEnabled(
true);
560 digitalChannelList->setEnabled(
true);
562 digitalDirectionList->setEnabled(
true);
564 digitalDirectionList->setEnabled(
false);
570 digitalDirectionList->setEnabled(
true);
574 digitalDirectionList->setEnabled(
false);
580 while((tmp >= 1000)&&(i))
585 periodEdit->setText(QString::number(
static_cast<unsigned long>(tmp)));
586 periodUnitList->setCurrentIndex(i);
590 void SystemControlPanel::receiveEvent(
const Event::Object *event)