iCub-main
Loading...
Searching...
No Matches
mainwindow.cpp
Go to the documentation of this file.
1#include "mainwindow.h"
2#include "ui_mainwindow.h"
3#include <QMessageBox>
4#include <QDebug>
5#include <math.h>
6#include <yarp/os/Log.h>
7
8MainWindow::MainWindow(ResourceFinder *rf,QWidget *parent) :
9 QMainWindow(parent),loadingWidget(this),
10 ui(new Ui::MainWindow)
11{
12 ui->setupUi(this);
13
14 this->rf = rf;
15 prevFreq = 0;
16 currentSampleFreq = 5;
17 smoothSliderPressed = false;
18
19 connect(&portThread,SIGNAL(portCreated()),
20 this,SLOT(onPortCreated()));
21 connect(&portThread,SIGNAL(openErrorDialog(QString)),
22 this,SLOT(onOpenErrorDialog(QString)));
23
24 portThread.start();
25
26 calibratingTimer.setInterval(100);
27 calibratingTimer.setSingleShot(false);
28 connect(&calibratingTimer,SIGNAL(timeout()),this,SLOT(onCalibratingTimer()),Qt::QueuedConnection);
29
30 connect(ui->btnCalibrate,SIGNAL(clicked()),this,SLOT(onCalibrate()));
31 connect(ui->btnShowTouchThres,SIGNAL(clicked()),this,SLOT(onThreashold()));
32 connect(ui->btnBinarization,SIGNAL(toggled(bool)),this,SLOT(onBinarization(bool)));
33 connect(ui->btnSmooth,SIGNAL(toggled(bool)),this,SLOT(onSmooth(bool)));
34 connect(ui->sliderScaleSmooth,SIGNAL(valueChanged(int)),this,SLOT(onSmoothValueChanged(int)));
35 connect(ui->sliderScaleSmooth,SIGNAL(sliderPressed()),this,SLOT(onSmoothValuePressed()));
36 connect(ui->sliderScaleSmooth,SIGNAL(sliderReleased()),this,SLOT(onSmoothValueReleased()));
37
38 connect(ui->spinNeighbor,SIGNAL(valueChanged(double)),this,SLOT(onSpinNeighborChanged(double)));
39 connect(ui->spinCompContactGain,SIGNAL(valueChanged(double)),this,SLOT(onSpinCompContactGainChanged(double)));
40 connect(ui->spinCompGain,SIGNAL(valueChanged(double)),this,SLOT(onSpinCompGainChanged(double)));
41 connect(ui->spinThreashold,SIGNAL(valueChanged(int)),this,SLOT(onSpinThresholdChanged(int)));
42
43 connect(ui->spinSampleFreq,SIGNAL(valueChanged(int)),this,SLOT(onSampleFreqChanged(int)));
44
45 updateTimer.setSingleShot(false);
46 updateTimer.setInterval(1000/currentSampleFreq);
47 connect(&updateTimer,SIGNAL(timeout()),this,SLOT(onUpdateTimer()));
48
49
50}
51
53{
54 delete ui;
55
56 portThread.closePorts();
57 portThread.stop();
58}
59
60void MainWindow::onOpenErrorDialog(QString msg)
61{
62 QMessageBox::critical(this,"Error",msg);
63}
64
65void MainWindow::onPortCreated()
66{
67 QString guiName = rf->check("name", Value("skinManGui")).asString().c_str();
68 QString guiRpcPortName = "/" + guiName + "/rpc:o";
69 QString guiMonitorPortName = "/" + guiName + "/monitor:i";
70 QString guiInfoPortName = "/" + guiName + "/info:i";
71
72 if (!portThread.guiRpcPort->open(guiRpcPortName.toLatin1().data())) {
73 QString msg = QString("Unable to open port %1").arg(guiRpcPortName);
74 QMessageBox::critical(this,"Error",msg);
75 return; //TODO EXIT
76 }
77 if (!portThread.driftCompMonitorPort->open(guiMonitorPortName.toLatin1().data())){
78 QString msg = QString("Unable to open port %1").arg(guiMonitorPortName);
79 QMessageBox::critical(this,"Error",msg);
80 return; //TODO EXIT
81 }
82 if (!portThread.driftCompInfoPort->open(guiInfoPortName.toLatin1().data())){
83 QString msg = QString("Unable to open port %1").arg(guiInfoPortName);
84 QMessageBox::critical(this,"Error",msg);
85 return; //TODO EXIT
86 }
87
88 portThread.driftCompInfoPort->setStrict();
89
90 initGui();
91
92}
93
95{
96 currentSampleFreq = 5;
97 currentSampleNum = 100;
98
99 // if the rpc port is connected, then initialize the gui status
100 initDone = false;
101 int outPorts = portThread.guiRpcPort->getOutputCount();
102 if(outPorts>0){
103 initDone = initGuiStatus();
104 }
105
106 if(initDone){
107 printLog("GUI connected!");
108 } else {
109 printLog("GUI not connected. Connect it to the module to make it work.");
110 }
111 // otherwise the gui will try to initialize every timeout (i.e. 1 sec)
112
113 updateTimer.start();
114}
115
116
117
119 Bottle reply = portThread.sendRpcCommand(true, get_binarization);
120 if(string(reply.toString().c_str()).compare("on") == 0){
121 ui->btnBinarization->setEnabled(true);
122 ui->btnBinarization->setText("ON");
123 ui->btnBinarization->setChecked(true);
124 }else{
125 ui->btnBinarization->setEnabled(true);
126 ui->btnBinarization->setText("OFF");
127 ui->btnBinarization->setChecked(false);
128 }
129
130 reply = portThread.sendRpcCommand(true, get_smooth_filter);
131 if(string(reply.toString().c_str()).compare("on") == 0){
132 ui->btnSmooth->setText("ON");
133 ui->sliderContainer->setEnabled(true);
134 ui->btnSmooth->setChecked(true);
135 }else{
136 ui->btnSmooth->setText("OFF");
137 ui->sliderContainer->setEnabled(false);
138 ui->btnSmooth->setChecked(false);
139 }
140
141 reply = portThread.sendRpcCommand(true, get_smooth_factor);
142 currentSmoothFactor = reply.get(0).asFloat64();
143 ui->sliderScaleSmooth->setValue(currentSmoothFactor * 10);
144
145 onSmoothValueChanged(currentSmoothFactor * 10);
146
147 reply = portThread.sendRpcCommand(true, get_threshold);
148 if(reply.isNull() || reply.size()==0 || !reply.get(0).isInt32()){
149 printLog("Error while getting the safety threshold");
150 return false;
151 }else{
152 currentThreshold = reply.get(0).asInt32();
153 ui->spinThreashold->setValue(currentThreshold);
154 }
155
156 reply = portThread.sendRpcCommand(true, get_gain);
157 if(reply.isNull() || reply.size()==0 || (!reply.get(0).isFloat64() && !reply.get(0).isInt32())){
158 printLog("Error while getting the compensation gain");
159 return false;
160 }else{
161 currentCompGain = reply.get(0).asFloat64();
162 ui->spinCompGain->setValue(currentCompGain);
163 }
164
165 reply = portThread.sendRpcCommand(true,get_cont_gain);
166 if(reply.isNull() || reply.size()==0 || (!reply.get(0).isFloat64() && !reply.get(0).isInt32())){
167 printLog("Error while getting the contact compensation gain");
168 return false;
169 }else{
170 currentContCompGain = reply.get(0).asFloat64();
171 ui->spinCompContactGain->setValue(currentContCompGain);
172 }
173
174 reply = portThread.sendRpcCommand(true,get_max_neigh_dist);
175 if(reply.isNull() || reply.size()==0 || (!reply.get(0).isFloat64() && !reply.get(0).isInt32())){
176 printLog("Error while getting the max neighbor distance");
177 return false;
178 }else{
179 currentMaxNeighDist = reply.get(0).asFloat64();
180 ui->spinNeighbor->setValue(currentMaxNeighDist * 100);
181 }
182
183 // get module information
184 reply = portThread.sendRpcCommand(true, get_info);
185 if(reply.isNull() || reply.size()!=3){
186 printLog("Error while reading the module information");
187 return false;
188 }
189 stringstream ss;
190 ss<< reply.get(0).toString().c_str()<< endl;
191 ss<< reply.get(1).toString().c_str()<< "\nInput ports:";
192 Bottle* portList = reply.get(2).asList();
193 portNames.resize(portList->size()/2);
194 portDim.resize(portList->size()/2);
195 //int numTaxels = 0;
196 for(unsigned int i=0;i<portDim.size();i++){
197 portNames[i] = portList->get(i*2).toString().c_str();
198 portDim[i] = portList->get(i*2+1).asInt32();
199 //numTaxels += portDim[i];
200 ss<< "\n - "<< portNames[i]<< " ("<< portDim[i]<< " taxels)";
201 }
202 ui->infoPanel->setPlainText(QString("%1").arg(ss.str().c_str()));
203
204
205 // check whether the skin calibration is in process
206 reply = portThread.sendRpcCommand(true, is_calibrating);
207 if(string(reply.toString().c_str()).compare("yes")==0){
208 loadingWidget.start();
209 calibratingTimer.start();
210 }
211
212 ui->controlsWidget->setEnabled(true);
213 ui->sampleFreqContainer->setEnabled(true);
214 ui->treeCompensation->setEnabled(true);
215 return true;
216}
217
218
219void MainWindow::onCalibratingTimer()
220{
221 Bottle reply = portThread.sendRpcCommand(true,is_calibrating);
222 if(string(reply.toString().c_str()).compare("yes")==0){
223 return;
224 }
225
226 ui->controlsWidget->setEnabled(true);
227 calibratingTimer.stop();
228 loadingWidget.stop();
229 printLog("Calibrating Done!");
230 QString msg = "Calibrating Done!";
231 ui->statusBar->showMessage(msg);
232 ui->infoPanel->appendPlainText(msg);
233
234}
235
236void MainWindow::onCalibrate()
237{
238 portThread.sendRpcCommand(false,calibrate);
239 loadingWidget.start("Calibrating...don't touch the skin!!");
240 calibratingTimer.start();
241 ui->controlsWidget->setEnabled(false);
242}
243
244void MainWindow::onSpinThresholdChanged(int value)
245{
246 int safetyThr = value;
247 if(safetyThr == currentThreshold)
248 return;
249
250 // set the threshold
251 Bottle b, setReply;
252 b.addInt32(set_threshold);
253 b.addInt32(safetyThr);
254 portThread.guiRpcPort->write(b, setReply);
255
256 // read the threshold
257 Bottle getReply = portThread.sendRpcCommand(true, get_threshold);
258 currentThreshold = getReply.get(0).asInt32();
259
260 if(safetyThr==currentThreshold){
261 QString msg = QString("Safety threshold changed: %1").arg(safetyThr);
262 ui->statusBar->showMessage(msg);
263 ui->infoPanel->appendPlainText(msg);
264 return;
265 }
266
267 QString msg = QString("Unable to set the threshold to: %1 m.\nSet command reply: %2").arg(safetyThr).arg(setReply.toString().c_str());
268 QMessageBox::critical(this,"Error",msg);
269
270 // setting the old value
271 ui->spinThreashold->setValue(currentThreshold);
272}
273
274void MainWindow::onSpinCompGainChanged(double value)
275{
276 double compGain = value;
277 if(compGain == currentCompGain)
278 return;
279
280 // set the gain
281 Bottle b, setReply;
282 b.addInt32(set_gain);
283 b.addFloat64(compGain);
284 portThread.guiRpcPort->write(b, setReply);
285
286 // read the gain
287 Bottle getReply = portThread.sendRpcCommand(true, get_gain);
288 currentCompGain = getReply.get(0).asFloat64();
289
290 if(compGain==currentCompGain){
291 QString msg = QString("Compensation gain changed: %1").arg(compGain);
292 ui->statusBar->showMessage(msg);
293 ui->infoPanel->appendPlainText(msg);
294 return;
295 }
296 QString msg = QString("Unable to set the compensation gain to: %1 m.\nSet command reply: %2").arg(compGain).arg(setReply.toString().c_str());
297 QMessageBox::critical(this,"Error",msg);
298
299 // setting the old value
300 ui->spinCompGain->setValue(currentCompGain);
301}
302
303void MainWindow::onSpinCompContactGainChanged(double value)
304{
305 double contCompGain = value;
306 if(contCompGain == currentContCompGain){
307 return;
308 }
309
310 // set the gain
311 Bottle b, setReply;
312 b.addInt32(set_cont_gain);
313 b.addFloat64(contCompGain);
314 portThread.guiRpcPort->write(b, setReply);
315
316 // read the gain
317 Bottle getReply = portThread.sendRpcCommand(true, get_cont_gain);
318 currentContCompGain = getReply.get(0).asFloat64();
319
320 if(contCompGain==currentContCompGain){
321 QString msg = QString("Contact compensation gain changed: %1").arg(contCompGain);
322 ui->statusBar->showMessage(msg);
323 ui->infoPanel->appendPlainText(msg);
324 return;
325 }
326
327 QString msg = QString("Unable to set the contact compensation gain to: %1 m.\nSet command reply: %2").arg(contCompGain).arg(setReply.toString().c_str());
328 QMessageBox::critical(this,"Error",msg);
329
330 // setting the old value
331 ui->spinCompContactGain->setValue(currentContCompGain);
332}
333
334void MainWindow::onSpinNeighborChanged(double value)
335{
336 double maxNeighDist = 1e-2*value; // TODO ????????????????????????????????????
337
338 if(maxNeighDist == currentMaxNeighDist){
339 return;
340 }
341
342 // set the value
343 Bottle b, setReply;
344 b.addInt32(set_max_neigh_dist);
345 b.addFloat64(maxNeighDist);
346 portThread.guiRpcPort->write(b, setReply);
347
348 // read the value
349 Bottle getReply = portThread.sendRpcCommand(true, get_max_neigh_dist);
350 currentMaxNeighDist = getReply.get(0).asFloat64();
351
352 if(maxNeighDist==currentMaxNeighDist){
353 QString msg = QString("Max neighbor distance changed: %1 m").arg(maxNeighDist);
354 ui->statusBar->showMessage(msg);
355 ui->infoPanel->appendPlainText(msg);
356 return;
357 }
358
359 QString msg = QString("Unable to set the max neighbor distance to: %1 m.\nSet command reply: %2").arg(maxNeighDist).arg(setReply.toString().c_str());
360 QMessageBox::critical(this,"Error",msg);
361 // setting the old value
362 ui->spinNeighbor->setValue(currentMaxNeighDist);
363
364}
365
366void MainWindow::onSmoothValuePressed()
367{
368 smoothSliderPressed = true;
369}
370
371void MainWindow::onSmoothValueReleased()
372{
373 if(!smoothSliderPressed){
374 return;
375 }
376
377 smoothSliderPressed = false;
378
379 changeSmooth(ui->sliderScaleSmooth->value());
380
381
382}
383
384void MainWindow::changeSmooth(int val)
385{
386 // check whether the smooth factor has changed
387 double value = (double)val/10;
388 double smoothFactor = round(value, 1); //double(int((value*10)+0.5))/10.0;
389 if(smoothFactor==currentSmoothFactor){
390 return;
391 }
392
393
394 // set the smooth factor
395 Bottle b, setReply;
396 b.addInt32(set_smooth_factor);
397 b.addFloat64(smoothFactor);
398 portThread.guiRpcPort->write(b, setReply);
399
400 // read the smooth factor
401 Bottle getReply = portThread.sendRpcCommand(true, get_smooth_factor);
402 currentSmoothFactor = getReply.get(0).asFloat64();
403 currentSmoothFactor = round(currentSmoothFactor, 1); //double(int((currentSmoothFactor*10)+0.5))/10.0;
404
405 if(smoothFactor==currentSmoothFactor){
406 QString msg = QString("Smooth factor changed: %1").arg(smoothFactor);
407 ui->statusBar->showMessage(msg);
408 ui->infoPanel->appendPlainText(msg);
409 return;
410 }
411 QString msg = QString("Unable to set the smooth factor to: %1\nSet command reply: ").arg(smoothFactor).arg(setReply.toString().c_str());
412 QMessageBox::critical(this,"Error",msg);
413 // setting the old value
414
415 ui->sliderScaleSmooth->setValue(currentSmoothFactor*10);
416}
417
418void MainWindow::onThreashold()
419{
420 Bottle touchThr = portThread.sendRpcCommand(true, get_touch_thr);
421 int index = 0;
422 for(unsigned int j=0; j<portDim.size(); j++){
423 stringstream msg;
424 msg<< "Thresholds for port "<< portNames[j]<< ":\n";
425 for(unsigned int i=0; i<portDim[j]; i++){
426 if(i%12==0){
427 if(i!=0){
428 msg<< "\n";
429 }
430 msg<< "TR"<< i/12<< ":\t";
431 }
432 msg << int(touchThr.get(index).asFloat64())<< ";\t";
433 index++;
434 }
435 QMessageBox::information(this,"Information",QString("%1").arg(msg.str().c_str()));
436 }
437}
438
439void MainWindow::onSmoothValueChanged(int val)
440{
441 QString d = QString("%L1").arg((double)val/10,0,'f',1);
442 ui->lblSmoothValue->setText(d);
443
444 int w = ui->sliderScaleSmooth->width() - 30;
445 double newX = ((double)w/(double)10) * (double)val;
446 ui->lblSmoothValue->setGeometry(newX,0,30,20);
447}
448
449void MainWindow::onSmooth(bool btnState)
450{
451 // if the button is off it means it is going to be turned on
452 if (btnState){
453 Bottle b, setReply;
454 b.addInt32(set_smooth_filter);
455 b.addString("on");
456 portThread.guiRpcPort->write(b, setReply);
457 Bottle reply = portThread.sendRpcCommand(true, get_smooth_filter);
458 if(string(reply.toString().c_str()).compare("on") == 0){
459 ui->btnSmooth->setText("ON");
460 ui->smoothControlContainer->setEnabled(true);
461 QString msg = "Smooth filter turned on";
462 ui->statusBar->showMessage(msg);
463 ui->infoPanel->appendPlainText(msg);
464 }else{
465 QString msg = QString("Error! Unable to turn the smooth filter on: %1").arg(reply.toString().c_str());
466 ui->statusBar->showMessage(msg);
467 ui->infoPanel->appendPlainText(msg);
468 }
469 } else {
470 Bottle b, setReply;
471 b.addInt32(set_smooth_filter); b.addString("off");
472 portThread.guiRpcPort->write(b, setReply);
473 Bottle reply = portThread.sendRpcCommand(true, get_smooth_filter);
474 if(string(reply.toString().c_str()).compare("off") == 0){
475 ui->btnSmooth->setText("OFF");
476 ui->smoothControlContainer->setEnabled(false);
477 QString msg = "Smooth filter turned off";
478 ui->statusBar->showMessage(msg);
479 ui->infoPanel->appendPlainText(msg);
480 }else{
481 QString msg = QString("Error! Unable to turn the smooth filter off: %1").arg(reply.toString().c_str());
482 ui->statusBar->showMessage(msg);
483 ui->infoPanel->appendPlainText(msg);
484 }
485 }
486}
487
488void MainWindow::onBinarization(bool btnState)
489{
490 if (btnState){
491 Bottle b, setReply;
492 b.addInt32(set_binarization);
493 b.addString("on");
494 portThread.guiRpcPort->write(b, setReply);
495 Bottle reply = portThread.sendRpcCommand(true, get_binarization);
496 if(string(reply.toString().c_str()).compare("on")==0){
497 ui->btnBinarization->setText("ON");
498 QString msg = "Binarization filter turned on";
499 ui->statusBar->showMessage(msg);
500 ui->infoPanel->appendPlainText(msg);
501 }else{
502 QString msg = QString("Error! Unable to turn the binarization filter on: %1").arg( reply.toString().c_str());
503 ui->statusBar->showMessage(msg);
504 ui->infoPanel->appendPlainText(msg);
505 }
506 } else {
507 Bottle b, setReply;
508 b.addInt32(set_binarization);
509 b.addString("off");
510 portThread.guiRpcPort->write(b, setReply);
511 Bottle reply = portThread.sendRpcCommand(true, get_binarization);
512 if(string(reply.toString().c_str()).compare("off")==0){
513 ui->btnBinarization->setText("OFF");
514 QString msg = "Binarization filter turned off";
515 ui->statusBar->showMessage(msg);
516 ui->infoPanel->appendPlainText(msg);
517 }else{
518 QString msg = QString("Error! Unable to turn the binarization filter off: %1").arg(reply.toString().c_str());
519 ui->statusBar->showMessage(msg);
520 ui->infoPanel->appendPlainText(msg);
521 }
522 }
523}
524
525
526void MainWindow::printLog(QString text)
527{
528 QString msg = text + "\n";
529 //ui->logPanel->appendPlainText(msg);
530 //qDebug() << msg;
531 yDebug("%s", msg.toLatin1().data());
532}
533
534double MainWindow::round(double value, int decimalDigit){
535 double q = pow(10.0, decimalDigit);
536 return double(int((value*q)+0.5))/q;
537}
538
539
540void MainWindow::onUpdateTimer()
541{
542 // if the gui has not been initialized yet
543 if(!initDone){
544 // if the rpc port is connected, then initialize the gui status
545 if(portThread.guiRpcPort->getOutputCount()>0){
546 initDone = initGuiStatus();
547 }
548
549 if(initDone){
550 printLog("GUI connected!");
551 } else {
552 return;
553 }
554 }
555
556 if(portThread.driftCompMonitorPort->getInputCount()==0){
557 setMsgFreq(false, 0);
558 }else{
559 Vector* b = portThread.driftCompMonitorPort->read(false);
560 if(!b || b->size()==0){
561 setMsgFreq(false, 0);
562 }else{
563 //set the frequency
564 double freq = (*b)[0];
565 setMsgFreq(true, freq);
566
567 // set the drift
568 int numTax = 0;
569 for(unsigned int i=0; i<portDim.size(); i++){
570 numTax += portDim[i];
571 }
572 const int numTr = numTax/12;
573 if(numTax>0){
574
575 // *** UPDATE DRIFT TREE VIEW (2ND TAB)
576 vector<float> driftPerTr(numTr);
577 double sumTr;
578 for(int i=0; i<numTr; i++){
579 sumTr=0;
580 for(int j=0; j<12; j++){
581 sumTr += (float) (*b)(i*12+j+1);
582 }
583 driftPerTr[i] = (float)round(sumTr/12.0, 2);
584 }
585
586 if(ui->treeCompensation->topLevelItemCount() <= 0){
587 for(size_t i=0; i<portNames.size();i++){
588 QTreeWidgetItem *portItem = new QTreeWidgetItem();
589 ui->treeCompensation->addTopLevelItem(portItem);
590
591 for(unsigned int j=0; j<portDim[i]/12; j++){
592 QTreeWidgetItem *trItem = new QTreeWidgetItem();
593 portItem->addChild(trItem);
594
595 for(int k=0; k<12; k++){
596 QTreeWidgetItem *taxelItem = new QTreeWidgetItem();
597 trItem->addChild(taxelItem);
598 }
599
600 }
601 }
602 }
603
604 double sumPort, meanPort;
605 stringstream trS, taxS;
606 int index=1;
607 int portIndex=0;
608 double meanTr;
609
610 for(size_t i=0; i<portNames.size();i++){
611 sumPort = 0;
612
613 QTreeWidgetItem *portItem = ui->treeCompensation->topLevelItem(i);
614
615 for(unsigned int j=0; j<portDim[i]/12; j++){
616 meanTr = driftPerTr[portIndex];
617 portIndex++;
618 sumPort += meanTr;
619 trS.str("");
620 trS<<j;
621
622 QTreeWidgetItem *trItem = portItem->child(j);
623 trItem->setText(1,trS.str().c_str());
624 trItem->setText(3,QString("%L1").arg(meanTr,0,'f',3));
625
626 for(int k=0; k<12; k++){
627 double drift = round((*b)(index), 2);
628 index++;
629 taxS.str("");
630 taxS<<k;
631 QTreeWidgetItem *taxelItem = trItem->child(k);
632 if(taxelItem){
633 taxelItem->setText(2,taxS.str().c_str());
634 taxelItem->setText(3,QString("%L1").arg(drift,0,'f',3));
635 }
636 }
637 }
638
639 meanPort = sumPort/(portDim[i]/12);
640 portItem->setText(0, portNames[i].c_str());
641 portItem->setText(3, QString("%L1").arg(meanPort,0,'f',3));
642 }
643
644 }
645 }
646 }
647
648 // check if there are messages on the info port
649 Bottle* infoMsg = portThread.driftCompInfoPort->read(false);
650 while(infoMsg){
651
652 printLog(infoMsg->toString().c_str());
653 infoMsg = portThread.driftCompInfoPort->read(false);
654 }
655}
656
657void MainWindow::onSampleFreqChanged(int value)
658{
659 if (value == currentSampleFreq || !updateTimer.isActive()){
660 return;
661 }
662 currentSampleFreq = value;
663 updateTimer.stop();
664 updateTimer.setInterval(1000/currentSampleFreq);
665 updateTimer.start();
666
667}
668
669void MainWindow::setMsgFreq(bool freqUpdated, double freq){
670 QString text;
671 double auxFreq = round(freq, 2);
672 if(freqUpdated){
673 text = QString("SkinDriftCompensation frequency: %L1").arg(freq,0,'f',3);
674 }else{
675 auxFreq = -1;
676 text = "Cannot read the frequency. Probably the skinDriftCompensation module has stopped working.";
677 }
678 if(auxFreq != prevFreq){
679 //ui->statusBar->showMessage(text);
680 ui->infoPanel->appendPlainText(text);
681 prevFreq = auxFreq;
682 }
683}
double round(double value, int decimalDigit)
void printLog(QString)
MainWindow(FirmwareUpdaterCore *core, bool adminMode, QWidget *parent=0)
bool initGuiStatus()
void initGui()
Port * guiRpcPort
Definition portthread.h:43
void closePorts()
BufferedPort< Vector > * driftCompMonitorPort
Definition portthread.h:44
Bottle sendRpcCommand(bool responseExpected, SkinManagerCommand cmd)
BufferedPort< Bottle > * driftCompInfoPort
Definition portthread.h:45
void stop()