source: trunk/FACT++/gui/MainWindow.cc@ 14607

Last change on this file since 14607 was 14442, checked in by tbretz, 12 years ago
Send proper exit code with KILL_SERVERS
File size: 20.0 KB
Line 
1#include "MainWindow.h"
2
3#include <iostream>
4#include <sstream>
5
6#include <QTimer>
7
8#include "src/Dim.h"
9
10#include "DockWindow.h"
11#include "HtmlDelegate.h"
12#include "CheckBoxDelegate.h"
13
14using namespace std;
15
16void MainWindow::MakeLEDs(QPushButton **arr, QGridLayout *lay, const char *slot) const
17{
18 arr[0]->setToolTip("Crate 0, Board 0, Index 0");
19
20 for (int i=1; i<40; i++)
21 {
22 QPushButton *b = new QPushButton(static_cast<QWidget*>(arr[0]->parent()));
23
24 b->setEnabled(arr[0]->isEnabled());
25 b->setSizePolicy(arr[0]->sizePolicy());
26 b->setMaximumSize(arr[0]->maximumSize());
27 b->setIcon(arr[0]->icon());
28 b->setIconSize(arr[0]->iconSize());
29 b->setCheckable(arr[0]->isCheckable());
30 b->setFlat(arr[0]->isFlat());
31
32 ostringstream str;
33 str << "Crate " << i/10 << ", Board " << i%10 << ", Index " << i;
34 b->setToolTip(str.str().c_str());
35
36 lay->addWidget(b, i/10+1, i%10+1, 1, 1);
37
38 arr[i] = b;
39 }
40
41 const QString name = arr[0]->objectName();
42
43 for (int i=0; i<40; i++)
44 {
45 arr[i]->setObjectName(name+QString::number(i));
46 QObject::connect(arr[i], SIGNAL(clicked()), this, slot);
47 }
48}
49
50MainWindow::MainWindow(QWidget *p) : QMainWindow(p)
51{
52 // setupUi MUST be called before the DimNetwork is initilized
53 // In this way it can be ensured that nothing from the
54 // DimNetwork arrives before all graphical elements are
55 // initialized. This is a simple but very powerfull trick.
56 setupUi(this);
57
58 // Now here we can do further setup which should be done
59 // before the gui is finally displayed.
60 fDimCmdServers->setItemDelegate(new CheckBoxDelegate);
61 fDimCmdCommands->setItemDelegate(new CheckBoxDelegate);
62 fDimCmdDescription->setItemDelegate(new HtmlDelegate);
63
64 fDimSvcServers->setItemDelegate(new CheckBoxDelegate);
65 fDimSvcServices->setItemDelegate(new CheckBoxDelegate);
66 fDimSvcDescription->setItemDelegate(new HtmlDelegate);
67
68 // Set a default string to be displayed in a the status bar at startup
69 fStatusBar->showMessage(PACKAGE_STRING" | "PACKAGE_URL" | report bugs to <"PACKAGE_BUGREPORT">");
70
71 // Initialize the 40 FTU Leds as a copy of the prototype LED
72 fFtuLED[0] = fFtuLEDPrototype;
73 MakeLEDs(fFtuLED, fFtuLedLayout, SLOT(slot_fFtuLED_clicked()));
74
75 // Initialize the 40 FAD Leds as a copy of the prototype LED
76 fFadLED[0] = fFadLEDPrototype;
77 MakeLEDs(fFadLED, fFadLedLayout, SLOT(slot_fFadLED_clicked()));
78
79 // Initialize a timer to update the displayed UTC time
80 QTimer *timer = new QTimer(this);
81 connect(timer, SIGNAL(timeout()), this, SLOT(slot_TimeUpdate()));
82 timer->start(100);
83}
84
85void MainWindow::slot_TimeUpdate()
86{
87 // Used toUTC to support also older Qt versions
88 // toTime_t() always returns the datetime converted to UTC
89 // dateTime() unfortunately returns our UTC always as LocalTime
90 QDateTime now = QDateTime::currentDateTime().toUTC();
91 now.setTimeSpec(Qt::LocalTime);
92
93 if (now.toTime_t()==fUTC->dateTime().toTime_t())
94 return;
95
96 fUTC->setDateTime(now);
97}
98
99
100void MainWindow::SelectTab(const QString &name)
101{
102 for (int i=0; i<fTabWidget->count(); i++)
103 if (fTabWidget->tabText(i)==name)
104 {
105 fTabWidget->setCurrentIndex(i);
106 break;
107 }
108}
109
110void MainWindow::on_fCommentInsertRow_clicked()
111{
112 if (fTableComments->model())
113 fTableComments->model()->insertRow(fTableComments->model()->rowCount());
114}
115
116void MainWindow::on_fNoutof4Val_valueChanged(int val)
117{
118 const uint32_t v[2] = { -1, val };
119
120 if (!fInHandler)
121 Dim::SendCommand("FTM_CONTROL/SET_N_OUT_OF_4", v);
122}
123
124void MainWindow::on_fRatesMin_valueChanged(int min)
125{
126 fRatesCanv->SetMin(min);
127}
128
129void MainWindow::on_fRatesMax_valueChanged(int max)
130{
131 fRatesCanv->SetMax(max);
132}
133
134void MainWindow::on_fShutdown_clicked()
135{
136 Dim::SendCommand("DIS_DNS/KILL_SERVERS", int(1));
137}
138
139void MainWindow::on_fShutdownAll_clicked()
140{
141 Dim::SendCommand("DIS_DNS/KILL_SERVERS", int(1));
142 Dim::SendCommand("DIS_DNS/EXIT", int(1));
143}
144
145void MainWindow::on_fTabWidget_tabCloseRequested(int which)
146{
147 // To get the correct size we have to switch to this tab
148 // An alternative would be to take the size of the current tab
149 fTabWidget->setCurrentIndex(which);
150
151 QWidget *w = fTabWidget->currentWidget(); //fTabWidget->widget(which);
152 if (!w)
153 {
154 cout << "Weird... the tab requested to be closed doesn't exist!" << endl;
155 return;
156 }
157
158 QDockWidget *d = w->findChild<QDockWidget*>();
159 if (!d)
160 {
161 cout << "Sorry, tab requested to be closed contains no QDockWidget!" << endl;
162 return;
163 }
164
165 new DockWindow(d, fTabWidget->tabText(which));
166 fTabWidget->removeTab(which);
167
168 if (fTabWidget->count()==1)
169 fTabWidget->setTabsClosable(false);
170}
171
172void MainWindow::on_fMcpStartRun_clicked()
173{
174 struct Value
175 {
176 uint64_t time;
177 uint64_t nevts;
178 char type[];
179 };
180
181 const int idx1 = fMcpRunType->currentIndex();
182 const int idx2 = fMcpTime->currentIndex();
183 const int idx3 = fMcpNumEvents->currentIndex();
184
185 const int64_t v2 = fMcpTime->itemData(idx2).toInt();
186 const int64_t v3 = fMcpNumEvents->itemData(idx3).toInt();
187
188 const QString rt = fMcpRunType->itemData(idx1).toString();
189
190 const size_t len = sizeof(Value)+rt.length()+1;
191
192 char *buf = new char[len];
193
194 Value *val = reinterpret_cast<Value*>(buf);
195
196 val->time = v2;
197 val->nevts = v3;
198
199 strcpy(val->type, rt.toStdString().c_str());
200
201 Dim::SendCommand("MCP/START", buf, len);
202
203 delete [] buf;
204
205}
206void MainWindow::on_fMcpStopRun_clicked()
207{
208 Dim::SendCommand("MCP/STOP");
209}
210
211void MainWindow::on_fMcpReset_clicked()
212{
213 Dim::SendCommand("MCP/RESET");
214}
215
216void MainWindow::on_fLoggerStart_clicked()
217{
218 Dim::SendCommand("DATA_LOGGER/START_RUN_LOGGING");
219}
220
221void MainWindow::on_fLoggerStop_clicked()
222{
223 Dim::SendCommand("DATA_LOGGER/STOP_RUN_LOGGING");
224}
225
226void MainWindow::on_fFtmStartRun_clicked()
227{
228 Dim::SendCommand("FTM_CONTROL/START_TRIGGER");
229}
230
231void MainWindow::on_fFtmStopRun_clicked()
232{
233 Dim::SendCommand("FTM_CONTROL/STOP_TRIGGER");
234}
235
236/*
237void MainWindow::on_fFadStartRun_clicked()
238{
239 Dim::SendCommand("FAD_CONTROL/START_RUN");
240}
241
242void MainWindow::on_fFadStopRun_clicked()
243{
244 Dim::SendCommand("FAD_CONTROL/STOP_RUN");
245}
246*/
247
248void MainWindow::on_fFadDrsOn_clicked()
249{
250 Dim::SendCommand("FAD_CONTROL/ENABLE_DRS", uint8_t(true));
251}
252
253void MainWindow::on_fFadDrsOff_clicked()
254{
255 Dim::SendCommand("FAD_CONTROL/ENABLE_DRS", uint8_t(false));
256}
257
258void MainWindow::on_fFadDwriteOn_clicked()
259{
260 Dim::SendCommand("FAD_CONTROL/ENABLE_DWRITE", uint8_t(true));
261}
262
263void MainWindow::on_fFadDwriteOff_clicked()
264{
265 Dim::SendCommand("FAD_CONTROL/ENABLE_DWRITE", uint8_t(false));
266}
267
268void MainWindow::on_fFadSingleTrigger_clicked()
269{
270 Dim::SendCommand("FAD_CONTROL/SEND_SINGLE_TRIGGER");
271}
272
273void MainWindow::on_fFadTriggerLineOn_clicked()
274{
275 Dim::SendCommand("FAD_CONTROL/ENABLE_TRIGGER_LINE", uint8_t(true));
276}
277
278void MainWindow::on_fFadTriggerLineOff_clicked()
279{
280 Dim::SendCommand("FAD_CONTROL/ENABLE_TRIGGER_LINE", uint8_t(false));
281}
282
283void MainWindow::on_fFadContTriggerOn_clicked()
284{
285 Dim::SendCommand("FAD_CONTROL/ENABLE_CONTINOUS_TRIGGER", uint8_t(true));
286}
287
288void MainWindow::on_fFadContTriggerOff_clicked()
289{
290 Dim::SendCommand("FAD_CONTROL/ENABLE_CONTINOUS_TRIGGER", uint8_t(false));
291}
292
293void MainWindow::on_fFadBusyOnOn_clicked()
294{
295 Dim::SendCommand("FAD_CONTROL/ENABLE_BUSY_ON", uint8_t(true));
296}
297
298void MainWindow::on_fFadBusyOnOff_clicked()
299{
300 Dim::SendCommand("FAD_CONTROL/ENABLE_BUSY_ON", uint8_t(false));
301}
302
303void MainWindow::on_fFadBusyOffOn_clicked()
304{
305 Dim::SendCommand("FAD_CONTROL/ENABLE_BUSY_OFF", uint8_t(true));
306}
307
308void MainWindow::on_fFadBusyOffOff_clicked()
309{
310 Dim::SendCommand("FAD_CONTROL/ENABLE_BUSY_OFF", uint8_t(false));
311}
312
313void MainWindow::on_fFadSocket0_clicked()
314{
315 Dim::SendCommand("FAD_CONTROL/ENABLE_COMMAND_SOCKET_MODE", uint8_t(true));
316}
317
318void MainWindow::on_fFadSocket17_clicked()
319{
320 Dim::SendCommand("FAD_CONTROL/ENABLE_COMMAND_SOCKET_MODE", uint8_t(false));
321}
322
323void MainWindow::on_fFadResetTriggerId_clicked()
324{
325 Dim::SendCommand("FAD_CONTROL/RESET_EVENT_COUNTER");
326}
327
328void MainWindow::FadSetFileFormat(uint16_t fmt)
329{
330 Dim::SendCommand("FAD_CONTROL/SET_FILE_FORMAT", fmt);
331}
332
333void MainWindow::on_fFadStart_clicked()
334{
335 Dim::SendCommand("FAD_CONTROL/START");
336}
337
338void MainWindow::on_fFadStop_clicked()
339{
340 Dim::SendCommand("FAD_CONTROL/STOP");
341}
342
343void MainWindow::on_fFadAbort_clicked()
344{
345 Dim::SendCommand("FAD_CONTROL/ABORT");
346}
347
348void MainWindow::on_fFadSoftReset_clicked()
349{
350 Dim::SendCommand("FAD_CONTROL/SOFT_RESET");
351}
352
353void MainWindow::on_fFadHardReset_clicked()
354{
355 Dim::SendCommand("FAD_CONTROL/HARD_RESET");
356}
357
358void MainWindow::slot_fFadLED_clicked()
359{
360 for (int32_t i=0; i<40; i++)
361 if (sender()==fFadLED[i])
362 {
363 Dim::SendCommand("FAD_CONTROL/TOGGLE", i);
364 break;
365 }
366}
367
368void MainWindow::on_fFadPrescalerCmd_valueChanged(int val)
369{
370 Dim::SendCommand("FAD_CONTROL/SET_TRIGGER_RATE", uint32_t(val));
371}
372
373void MainWindow::on_fFadRunNumberCmd_valueChanged(int val)
374{
375 Dim::SendCommand("FAD_CONTROL/SET_RUN_NUMBER", uint64_t(val));
376}
377
378void MainWindow::on_fFadRoiCmd_valueChanged(int)
379{
380 const int32_t vals1[2] = { -1, fFadRoiCmd->value() };
381 Dim::SendCommand("FAD_CONTROL/SET_REGION_OF_INTEREST", vals1);
382
383 for (int ch=8; ch<36; ch+=9)
384 {
385 const int32_t vals2[2] = { ch, fFadRoiCh9Cmd->value() };
386 Dim::SendCommand("FAD_CONTROL/SET_REGION_OF_INTEREST", vals2);
387 }
388}
389
390void MainWindow::FadDacCmd_valueChanged(uint16_t val, uint16_t idx)
391{
392 const uint32_t cmd[2] = { idx, val };
393 Dim::SendCommand("FAD_CONTROL/SET_DAC_VALUE", cmd);
394}
395
396void MainWindow::on_fDrsCalibStart_clicked()
397{
398 Dim::SendCommand("FAD_CONTROL/START_DRS_CALIBRATION");
399}
400
401void MainWindow::on_fDrsCalibReset_clicked()
402{
403 Dim::SendCommand("FAD_CONTROL/RESET_SECONDARY_DRS_BASELINE");
404}
405
406void MainWindow::SetTriggerSequence()
407{
408 const uint16_t d[3] =
409 {
410 uint16_t(fTriggerSeqPed->value()),
411 uint16_t(fTriggerSeqLPext->value()),
412 uint16_t(fTriggerSeqLPint->value())
413 };
414
415 if (!fInHandler)
416 Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_SEQUENCE", d);
417}
418
419/*
420void MainWindow::on_fEnableTrigger_clicked(bool b)
421{
422 Dim::SendCommand("FTM_CONTROL/ENABLE_TRIGGER", b);
423}
424
425void MainWindow::on_fEnableExt1_clicked(bool b)
426{
427 Dim::SendCommand("FTM_CONTROL/ENABLE_EXT1", b);
428}
429
430void MainWindow::on_fEnableExt2_clicked(bool b)
431{
432 Dim::SendCommand("FTM_CONTROL/ENABLE_EXT2", b);
433}
434
435void MainWindow::on_fEnableVeto_clicked(bool b)
436{
437 Dim::SendCommand("FTM_CONTROL/ENABLE_VETO", b);
438}
439*/
440void MainWindow::on_fPhysicsCoincidence_valueChanged(int v)
441{
442 if (!fInHandler)
443 Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_MULTIPLICITY", v);
444}
445
446void MainWindow::on_fPhysicsWindow_valueChanged(int v)
447{
448 if (!fInHandler)
449 Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_WINDOW", v/4-2);
450}
451
452void MainWindow::on_fCalibCoincidence_valueChanged(int v)
453{
454 if (!fInHandler)
455 Dim::SendCommand("FTM_CONTROL/SET_CALIBRATION_MULTIPLICITY", v);
456}
457
458void MainWindow::on_fCalibWindow_valueChanged(int v)
459{
460 if (!fInHandler)
461 Dim::SendCommand("FTM_CONTROL/SET_CALIBRATION_WINDOW", v/4-2);
462}
463
464void MainWindow::on_fTriggerInterval_valueChanged(int val)
465{
466 if (!fInHandler)
467 Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_INTERVAL", val);
468}
469
470void MainWindow::on_fTriggerDelay_valueChanged(int val)
471{
472 if (!fInHandler)
473 Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_DELAY", val/4-2);
474}
475
476void MainWindow::on_fTimeMarkerDelay_valueChanged(int val)
477{
478 if (!fInHandler)
479 Dim::SendCommand("FTM_CONTROL/SET_TIME_MARKER_DELAY", val/4-2);
480}
481
482void MainWindow::on_fDeadTime_valueChanged(int val)
483{
484 if (!fInHandler)
485 Dim::SendCommand("FTM_CONTROL/SET_DEAD_TIME", val/4-2);
486}
487
488void MainWindow::on_fPrescalingVal_valueChanged(int val)
489{
490 if (!fInHandler)
491 Dim::SendCommand("FTM_CONTROL/SET_PRESCALING", val);
492}
493
494void MainWindow::on_fPixelEnableAll_clicked()
495{
496 Dim::SendCommand("FTM_CONTROL/ENABLE_PIXEL", int16_t(-1));
497}
498
499void MainWindow::on_fPixelDisableAll_clicked()
500{
501 Dim::SendCommand("FTM_CONTROL/DISABLE_PIXEL", int16_t(-1));
502}
503
504void MainWindow::on_fEnableTrigger_stateChanged(int b)
505{
506 if (!fInHandler)
507 Dim::SendCommand("FTM_CONTROL/ENABLE_TRIGGER", b==Qt::Checked);
508}
509
510void MainWindow::on_fEnableExt1_stateChanged(int b)
511{
512 if (!fInHandler)
513 Dim::SendCommand("FTM_CONTROL/ENABLE_EXT1", b==Qt::Checked);
514}
515
516void MainWindow::on_fEnableExt2_stateChanged(int b)
517{
518 if (!fInHandler)
519 Dim::SendCommand("FTM_CONTROL/ENABLE_EXT2", b==Qt::Checked);
520}
521
522void MainWindow::on_fEnableClockCond_stateChanged(int b)
523{
524 if (!fInHandler)
525 Dim::SendCommand("FTM_CONTROL/ENABLE_CLOCK_CONDITIONER", b==Qt::Checked);
526}
527
528void MainWindow::on_fEnableVeto_stateChanged(int b)
529{
530 if (!fInHandler)
531 Dim::SendCommand("FTM_CONTROL/ENABLE_VETO", b==Qt::Checked);
532}
533
534void MainWindow::on_fClockCondFreq_activated(int idx)
535{
536 if (!fInHandler)
537 Dim::SendCommand("FTM_CONTROL/SET_CLOCK_FREQUENCY", fClockCondFreq->itemData(idx).toInt());
538}
539
540void MainWindow::slot_fFtuLED_clicked()
541{
542 for (int32_t i=0; i<40; i++)
543 if (sender()==fFtuLED[i])
544 {
545 Dim::SendCommand("FTM_CONTROL/TOGGLE_FTU", i);
546 break;
547 }
548}
549
550void MainWindow::on_fFtuPing_toggled(bool checked)
551{
552 if (checked)
553 Dim::SendCommand("FTM_CONTROL/PING");
554}
555
556void MainWindow::on_fFtuAllOn_clicked()
557{
558 static const struct Data { int32_t id; char on; } __attribute__((__packed__)) d = { -1, 1 };
559 Dim::SendCommand("FTM_CONTROL/ENABLE_FTU", &d, sizeof(Data));
560}
561
562void MainWindow::on_fFtuAllOff_clicked()
563{
564 static const struct Data { int32_t id; char on; } __attribute__((__packed__)) d = { -1, 0 };
565 Dim::SendCommand("FTM_CONTROL/ENABLE_FTU", &d, sizeof(Data));
566}
567
568void MainWindow::on_fLpIntIntensity_valueChanged(int val)
569{
570 if (!fInHandler)
571 Dim::SendCommand("FTM_CONTROL/SET_INTENSITY_LPINT", uint16_t(val));
572}
573
574void MainWindow::on_fLpExtIntensity_valueChanged(int val)
575{
576 if (!fInHandler)
577 Dim::SendCommand("FTM_CONTROL/SET_INTENSITY_LPEXT", uint16_t(val));
578}
579
580void MainWindow::on_fLpIntGroup1_stateChanged(int b)
581{
582 if (!fInHandler)
583 Dim::SendCommand("FTM_CONTROL/ENABLE_GROUP1_LPINT", uint8_t(b));
584}
585
586void MainWindow::on_fLpExtGroup1_stateChanged(int b)
587{
588 if (!fInHandler)
589 Dim::SendCommand("FTM_CONTROL/ENABLE_GROUP1_LPEXT", uint8_t(b));
590}
591
592void MainWindow::on_fLpIntGroup2_stateChanged(int b)
593{
594 if (!fInHandler)
595 Dim::SendCommand("FTM_CONTROL/ENABLE_GROUP2_LPINT", uint8_t(b));
596}
597
598void MainWindow::on_fLpExtGroup2_stateChanged(int b)
599{
600 if (!fInHandler)
601 Dim::SendCommand("FTM_CONTROL/ENABLE_GROUP2_LPEXT", uint8_t(b));
602}
603
604void MainWindow::on_fFeedbackDevMin_valueChanged(int min)
605{
606 fFeedbackDevCam->SetMin(min);
607 fFeedbackDevCam->updateCamera();
608}
609
610void MainWindow::on_fFeedbackDevMax_valueChanged(int max)
611{
612 fFeedbackDevCam->SetMax(max);
613 fFeedbackDevCam->updateCamera();
614}
615
616void MainWindow::on_fFeedbackCmdMin_valueChanged(int min)
617{
618 fFeedbackCmdCam->SetMin(min);
619 fFeedbackCmdCam->updateCamera();
620}
621
622void MainWindow::on_fFeedbackCmdMax_valueChanged(int max)
623{
624 fFeedbackCmdCam->SetMax(max);
625 fFeedbackCmdCam->updateCamera();
626}
627
628void MainWindow::on_fFeedbackTempStart_clicked()
629{
630 Dim::SendCommand("FEEDBACK/START_TEMP_CONTROL",
631 (float)fFeedbackTempOffset->value());
632}
633
634void MainWindow::on_fFeedbackOutputEnable_clicked()
635{
636 Dim::SendCommand("FEEDBACK/ENABLE_OUTPUT", uint8_t(1));
637}
638
639void MainWindow::on_fFeedbackOutputDisable_clicked()
640{
641 Dim::SendCommand("FEEDBACK/ENABLE_OUTPUT", uint8_t(0));
642}
643
644void MainWindow::on_fFeedbackStop_clicked()
645{
646 Dim::SendCommand("FEEDBACK/STOP");
647}
648
649void MainWindow::on_fFeedbackCalibrate_clicked()
650{
651 Dim::SendCommand("FEEDBACK/CALIBRATE_CURRENTS");
652}
653
654void MainWindow::on_fBiasVoltDac_valueChanged(int val)
655{
656 fBiasVoltDacVolt->setValue(val*90./4096);
657}
658
659void MainWindow::on_fBiasOffsetDac_valueChanged(int val)
660{
661 fBiasOffsetDacVolt->setValue(val*90./4096);
662}
663
664/*
665void MainWindow::on_fBiasRequestStatus_clicked()
666{
667 if (!fInHandler)
668 Dim::SendCommand("BIAS_CONTROL/REQUEST_STATUS");
669}
670*/
671
672void MainWindow::on_fBiasApplyReference_clicked()
673{
674 if (!fInHandler)
675 Dim::SendCommand("BIAS_CONTROL/SET_GLOBAL_OFFSET_TO_ZERO");
676}
677
678void MainWindow::on_fBiasSetToZero_clicked()
679{
680 if (!fInHandler)
681 Dim::SendCommand("BIAS_CONTROL/SET_ZERO_VOLTAGE");
682}
683
684void MainWindow::on_fBiasReset_clicked()
685{
686 if (!fInHandler)
687 Dim::SendCommand("BIAS_CONTROL/RESET_OVER_CURRENT_STATUS");
688}
689
690
691void MainWindow::on_fBiasApplyChVolt_clicked() // SET_CHANNEL_VOLTAGE
692{
693 if (fInHandler)
694 return;
695
696 const struct Data { uint16_t ch; float val; } __attribute__((__packed__)) val = {
697 uint16_t(fBiasHvBoard->value()*32+fBiasHvChannel->value()),
698 float(fBiasVolt->value())
699 };
700
701 Dim::SendCommand("BIAS_CONTROL/SET_CHANNEL_VOLTAGE", &val, sizeof(Data));
702}
703
704void MainWindow::on_fBiasApplyChDac_clicked()
705{
706 if (fInHandler)
707 return;
708
709 const uint16_t val[2] =
710 {
711 uint16_t(fBiasHvBoard->value()*32+fBiasHvChannel->value()),
712 uint16_t(fBiasVoltDac->value())
713 };
714
715 Dim::SendCommand("BIAS_CONTROL/SET_CHANNEL_DAC", val);
716}
717
718void MainWindow::on_fBiasApplyGlobalVolt_clicked()
719{
720 if (!fInHandler)
721 Dim::SendCommand("BIAS_CONTROL/SET_GLOBAL_VOLTAGE", float(fBiasVolt->value()));
722}
723
724void MainWindow::on_fBiasApplyGlobalDac_clicked()
725{
726 if (!fInHandler)
727 Dim::SendCommand("BIAS_CONTROL/SET_GLOBAL_DAC", uint16_t(fBiasVoltDac->value()));
728}
729
730void MainWindow::on_fBiasAddOffsetChVolt_clicked()
731{
732 if (fInHandler)
733 return;
734
735 const struct Data { uint16_t ch; float val; } __attribute__((__packed__)) val = {
736 uint16_t(fBiasHvBoard->value()*32+fBiasHvChannel->value()),
737 float(fBiasOffsetVolt->value())
738 };
739
740 Dim::SendCommand("BIAS_CONTROL/INCREASE_CHANNEL_VOLTAGE", &val, sizeof(Data));
741}
742
743void MainWindow::on_fBiasAddOffsetGlobalVolt_clicked()
744{
745 if (!fInHandler)
746 Dim::SendCommand("BIAS_CONTROL/INCREASE_GLOBAL_VOLTAGE", float(fBiasOffsetVolt->value()));
747}
748
749void MainWindow::on_fBiasAddOffsetChDac_clicked()
750{
751}
752
753void MainWindow::on_fBiasAddOffsetGlobalDac_clicked()
754{
755}
756
757void MainWindow::on_fBiasApplyOffsetChVolt_clicked()
758{
759 if (fInHandler)
760 return;
761
762 const struct Data { uint16_t ch; float val; } __attribute__((__packed__)) val = {
763 uint16_t(fBiasHvBoard->value()*32+fBiasHvChannel->value()),
764 float(fBiasOffsetVolt->value())
765 };
766
767 Dim::SendCommand("BIAS_CONTROL/SET_CHANNEL_OFFSET", &val, sizeof(Data));
768}
769
770void MainWindow::on_fBiasApplyOffsetGlobalVolt_clicked()
771{
772 if (!fInHandler)
773 Dim::SendCommand("BIAS_CONTROL/SET_GLOBAL_OFFSET", float(fBiasOffsetVolt->value()));
774}
775
776/*
777void MainWindow::on_fBiasApplyReferenceCh_clicked()
778{
779 if (!fInHandler)
780 Dim::SendCommand("BIAS_CONTROL/SET_CHANNEL_OFFSET_TO_ZERO",
781 uint16_t(fBiasHvBoard->value()*32+fBiasHvChannel->value()));
782}*/
783
784void MainWindow::on_fBiasVoltMin_valueChanged(int min)
785{
786 fBiasCamV->SetMin(min);
787 fBiasCamV->updateCamera();
788}
789
790void MainWindow::on_fBiasVoltMax_valueChanged(int max)
791{
792 fBiasCamV->SetMax(max);
793 fBiasCamV->updateCamera();
794}
795
796void MainWindow::on_fBiasCurrentMin_valueChanged(int min)
797{
798 fBiasCamA->SetMin(min);
799 fBiasCamA->updateCamera();
800}
801
802void MainWindow::on_fBiasCurrentMax_valueChanged(int max)
803{
804 fBiasCamA->SetMax(max);
805 fBiasCamA->updateCamera();
806}
807
808void MainWindow::on_fChatSend_clicked()
809{
810 const string msg = fChatMessage->text().toStdString();
811 if (Dim::SendCommand("CHAT/MSG", msg.c_str(), msg.length()+1))
812 fChatMessage->clear();
813}
814
815void MainWindow::on_fStatusLoggerLed_clicked()
816{
817 SelectTab("Logger");
818}
819
820void MainWindow::on_fStatusChatLed_clicked()
821{
822 SelectTab("Chat");
823}
824
825void MainWindow::on_fStatusFTMLed_clicked()
826{
827 SelectTab("Trigger");
828}
829
830void MainWindow::on_fStatusFTULed_clicked()
831{
832 SelectTab("FTUs");
833}
834
835void MainWindow::on_fStatusFADLed_clicked()
836{
837 SelectTab("FAD");
838}
Note: See TracBrowser for help on using the repository browser.