10 #include "ui_triaclight.h"
12 #include <QMessageBox>
14 #include <QTextStream>
17 #include <QStandardItemModel>
19 #include <QtSerialPort/QSerialPort>
20 #include <QtSerialPort/QSerialPortInfo>
30 foreach (
const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
32 ui->serialPortCombo->addItem(info.portName());
33 QString tooltip(
"Manufacturer: ");
34 if(info.manufacturer() !=
"")
35 tooltip.append(info.manufacturer());
37 tooltip.append(
"None");
39 tooltip.append(
"\nDescription: ");
41 if(info.description() !=
"")
42 tooltip.append(info.description());
44 tooltip.append(
"None");
45 ui->serialPortCombo->setItemData(count++, tooltip, Qt::ToolTipRole);
53 pus[0]->AttachToGui(
ui->l1label,
ui->buttonl1_on,
ui->buttonl1_off,
ui->l1levelslider);
54 pus[1]->AttachToGui(
ui->l2label,
ui->buttonl2_on,
ui->buttonl2_off,
ui->l2levelslider);
55 pus[2]->AttachToGui(
ui->relabel,
ui->buttonre_on,
ui->buttonre_off,
ui->relevelslider);
57 connect(
ui->serialPortOpenButton, SIGNAL(clicked()),
this, SLOT(
OpenPort()));
58 connect(
ui->serialPortCloseButton, SIGNAL(clicked()),
this, SLOT(
ClosePort()));
59 connect(
ui->serialPortReset, SIGNAL(clicked()),
this, SLOT(
ResetPort()));
61 connect(
ui->updateButton, SIGNAL(clicked()),
this, SLOT(
UpdateInfo()));
62 ui->updateButton->setEnabled(
false);
64 connect(
ui->actionExit, SIGNAL(triggered()),
this, SLOT(close()));
68 dimmerData->setHorizontalHeaderItem(0,
new QStandardItem(QString(
"Power Unit")));
69 dimmerData->setHorizontalHeaderItem(1,
new QStandardItem(QString(
"Level")));
70 dimmerData->setHorizontalHeaderItem(2,
new QStandardItem(QString(
"Compare Val")));
76 ui->dimmerTable->setRowHeight(i,20);
77 for(
int j = 0; j < 3; j++)
84 ui->statusBar->showMessage(
"Disconnected");
108 QString port =
ui->serialPortCombo->currentText();
109 ui->statusBar->showMessage(QString(
"Connecting to %1").arg(port));
113 ui->statusBar->showMessage(QString(
"Connected to %1").arg(port));
114 ui->updateButton->setEnabled(
true);
116 for_each(
pus.begin(),
pus.end(), [](QSharedPointer<PUInterfaceGUI> & spu) { spu->SyncGUI(); });
125 ui->statusBar->showMessage(
"Disconnected");
131 ui->freqrawRisingDisplay->display(0);
132 ui->freqrawFallingDisplay->display(0);
133 ui->freqrawAvgDisplay->display(0);
135 ui->freqRisingDisplay->display(0);
136 ui->freqFallingDisplay->display(0);
137 ui->freqAvgDisplay->display(0);
141 for(
int j = 0; j < 3; j++)
150 ui->updateButton->setEnabled(
false);
151 ui->statusBar->showMessage(
"Disconnected");
155 for_each(
pus.begin(),
pus.end(), [](QSharedPointer<PUInterfaceGUI> & spu) { spu->Reset(); });
171 return low + (high << 8);
191 QByteArray info =
mc->RetrieveInfo();
199 double averagefreq = (fallingfreq + risingfreq)/2.0;
200 ui->freqrawAvgDisplay->display(averagefreq);
205 ui->freqFallingDisplay->display(fallingfreq);
206 ui->freqRisingDisplay->display(risingfreq);
207 ui->freqAvgDisplay->display(averagefreq);
213 if((qint8)info[off+4*i] == 0u)
222 dimmerData->item(i,1)->setText(QString(
"%1%").arg(quint16(info[off+1+4*i])));
249 QTextStream err(&errstr);
250 err << e.what() <<
"\n";
256 QMessageBox::information(
this,
"BPLightContraption Error", errstr);