-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnectdialog.cpp
More file actions
48 lines (42 loc) · 1.03 KB
/
connectdialog.cpp
File metadata and controls
48 lines (42 loc) · 1.03 KB
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
#include "connectdialog.h"
#include "ui_connectdialog.h"
#include <QMessageBox>
#include <QDebug>
ConnectDialog::ConnectDialog(GpibInstrument& m_instr, QWidget *parent) :
QDialog(parent), ui(new Ui::ConnectDialog), instr(m_instr)
{
ui->setupUi(this);
}
ConnectDialog::~ConnectDialog()
{
delete ui;
}
void ConnectDialog::on_cmdCancel_clicked()
{
this->reject();
}
void ConnectDialog::on_cmdSearch_clicked()
{
ui->cmdConnect->setEnabled(false);
ui->listVisaAddr->clear();
}
void ConnectDialog::on_cmdConnect_clicked()
{
bool connectedState = false;
connectedState = instr.openInstrument(ui->spinBoxGpibAddr->value());
if(connectedState)
{
QString idn = instr.query("*IDN?");
QMessageBox::information(this, "Connection successfull", QString("Successfully connected to instrument!\n"
"IDN: ") + idn);
this->accept();
}
else
{
QMessageBox::warning(this, "Connection failed", "Connection to instrument failed!");
}
}
void ConnectDialog::on_listVisaAddr_currentItemChanged()
{
ui->cmdConnect->setEnabled(true);
}