New AMBE engine (2)

pull/398/head
f4exb 2019-07-20 05:47:22 +02:00
rodzic 8d6a69eec6
commit f04b6eb975
7 zmienionych plików z 197 dodań i 25 usunięć

Wyświetl plik

@ -180,7 +180,7 @@ std::string AMBEEngine::get_driver(const std::string& tty)
bool AMBEEngine::scan(std::vector<QString>& ambeDevices)
{
getComList();
std::list<std::string>::iterator it = m_comList.begin();
std::list<std::string>::const_iterator it = m_comList.begin();
ambeDevices.clear();
while (it != m_comList.end())
@ -236,6 +236,7 @@ void AMBEEngine::releaseController(const std::string& deviceRef)
it->thread->wait(100);
it->worker->m_inputMessageQueue.clear();
it->worker->close();
m_controllers.erase(it);
qDebug() << "DVSerialEngine::releaseController: closed device at: " << it->device.c_str();
break;
}
@ -263,13 +264,13 @@ void AMBEEngine::releaseAll()
m_controllers.clear();
}
void AMBEEngine::getDeviceRefs(std::vector<std::string>& deviceNames)
void AMBEEngine::getDeviceRefs(std::vector<QString>& deviceNames)
{
std::vector<AMBEController>::iterator it = m_controllers.begin();
std::vector<AMBEController>::const_iterator it = m_controllers.begin();
while (it != m_controllers.end())
{
deviceNames.push_back(it->device);
deviceNames.push_back(QString(it->device.c_str()));
++it;
}
}

Wyświetl plik

@ -44,7 +44,7 @@ public:
void releaseAll();
int getNbDevices() const { return m_controllers.size(); } //!< number of devices used
void getDeviceRefs(std::vector<std::string>& devicesRefs); //!< reference of the devices used (device path or url)
void getDeviceRefs(std::vector<QString>& devicesRefs); //!< reference of the devices used (device path or url)
bool registerController(const std::string& deviceRef); //!< create a new controller for the device in reference
void releaseController(const std::string& deviceRef); //!< release controller resources for the device in reference
@ -74,8 +74,7 @@ private:
std::list<std::string> m_comList;
std::list<std::string> m_comList8250;
std::vector<std::string> m_ambeSerial;
std::vector<AMBEController> m_controllers;
std::vector<AMBEController> m_controllers;
QMutex m_mutex;
};

Wyświetl plik

@ -17,6 +17,7 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QString>
#include <QListWidgetItem>
#include "ambedevicesdialog.h"
#include "ui_ambedevicesdialog.h"
@ -28,6 +29,7 @@ AMBEDevicesDialog::AMBEDevicesDialog(AMBEEngine& ambeEngine, QWidget* parent) :
{
ui->setupUi(this);
populateSerialList();
refreshInUseList();
}
AMBEDevicesDialog::~AMBEDevicesDialog()
@ -39,10 +41,141 @@ void AMBEDevicesDialog::populateSerialList()
{
std::vector<QString> ambeSerialDevices;
m_ambeEngine.scan(ambeSerialDevices);
ui->ambeSerialDevices->clear();
std::vector<QString>::const_iterator it = ambeSerialDevices.begin();
for (; it != ambeSerialDevices.end(); ++it)
{
ui->ambeSerialDevices->addItem(QString(*it));
}
}
}
void AMBEDevicesDialog::refreshInUseList()
{
std::vector<QString> inUseDevices;
m_ambeEngine.getDeviceRefs(inUseDevices);
ui->ambeDeviceRefs->clear();
std::vector<QString>::const_iterator it = inUseDevices.begin();
for (; it != inUseDevices.end(); ++it)
{
qDebug("AMBEDevicesDialog::refreshInUseList: %s", qPrintable(*it));
ui->ambeDeviceRefs->addItem(*it);
}
}
void AMBEDevicesDialog::on_importSerial_clicked(bool checked)
{
(void) checked;
QListWidgetItem *serialItem = ui->ambeSerialDevices->currentItem();
if (!serialItem)
{
ui->statusText->setText("No selection");
return;
}
QString serialName = serialItem->text();
QList<QListWidgetItem*> foundItems = ui->ambeDeviceRefs->findItems(serialName, Qt::MatchFixedString|Qt::MatchCaseSensitive);
if (foundItems.size() == 0)
{
if (m_ambeEngine.registerController(serialName.toStdString()))
{
ui->ambeDeviceRefs->addItem(serialName);
ui->statusText->setText(tr("%1 added").arg(serialName));
}
else
{
ui->statusText->setText(tr("Cannot open %1").arg(serialName));
}
}
else
{
ui->statusText->setText("Device already in use");
}
}
void AMBEDevicesDialog::on_importAllSerial_clicked(bool checked)
{
(void) checked;
int count = 0;
for (int i = 0; i < ui->ambeSerialDevices->count(); i++)
{
const QListWidgetItem *serialItem = ui->ambeSerialDevices->item(i);
QString serialName = serialItem->text();
QList<QListWidgetItem*> foundItems = ui->ambeDeviceRefs->findItems(serialName, Qt::MatchFixedString|Qt::MatchCaseSensitive);
if (foundItems.size() == 0)
{
if (m_ambeEngine.registerController(serialName.toStdString()))
{
ui->ambeDeviceRefs->addItem(serialName);
count++;
}
}
}
ui->statusText->setText(tr("%1 devices added").arg(count));
}
void AMBEDevicesDialog::on_removeAmbeDevice_clicked(bool checked)
{
(void) checked;
QListWidgetItem *deviceItem = ui->ambeDeviceRefs->currentItem();
if (!deviceItem)
{
ui->statusText->setText("No selection");
return;
}
QString deviceName = deviceItem->text();
m_ambeEngine.releaseController(deviceName.toStdString());
ui->statusText->setText(tr("%1 removed").arg(deviceName));
refreshInUseList();
}
void AMBEDevicesDialog::on_refreshAmbeList_clicked(bool checked)
{
refreshInUseList();
ui->statusText->setText("In use refreshed");
}
void AMBEDevicesDialog::on_clearAmbeList_clicked(bool checked)
{
if (ui->ambeDeviceRefs->count() == 0)
{
ui->statusText->setText("No active items");
return;
}
m_ambeEngine.releaseAll();
ui->ambeDeviceRefs->clear();
ui->statusText->setText("All items released");
}
void AMBEDevicesDialog::on_importAddress_clicked(bool checked)
{
QString addressAndPort = ui->ambeAddressText->text();
QList<QListWidgetItem*> foundItems = ui->ambeDeviceRefs->findItems(addressAndPort, Qt::MatchFixedString|Qt::MatchCaseSensitive);
if (foundItems.size() == 0)
{
if (m_ambeEngine.registerController(addressAndPort.toStdString()))
{
ui->ambeDeviceRefs->addItem(addressAndPort);
ui->statusText->setText(tr("%1 added").arg(addressAndPort));
}
else
{
ui->statusText->setText(tr("Cannot open %1").arg(addressAndPort));
}
}
else
{
ui->statusText->setText("Address already in use");
}
}

Wyświetl plik

@ -39,9 +39,18 @@ public:
private:
void populateSerialList();
void refreshInUseList();
Ui::AMBEDevicesDialog* ui;
AMBEEngine& m_ambeEngine;
private slots:
void on_importSerial_clicked(bool checked);
void on_importAllSerial_clicked(bool checked);
void on_removeAmbeDevice_clicked(bool checked);
void on_refreshAmbeList_clicked(bool checked);
void on_clearAmbeList_clicked(bool checked);
void on_importAddress_clicked(bool checked);
};
#endif // SDRGUI_GUI_AMBEDEVICESDIALOG_H_

Wyświetl plik

@ -16,9 +16,9 @@
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>50</x>
<x>310</x>
<y>410</y>
<width>341</width>
<width>81</width>
<height>32</height>
</rect>
</property>
@ -73,7 +73,7 @@
<rect>
<x>10</x>
<y>10</y>
<width>171</width>
<width>201</width>
<height>17</height>
</rect>
</property>
@ -93,6 +93,9 @@
<property name="toolTip">
<string>AMBE server address as ip:port</string>
</property>
<property name="inputMask">
<string>000.000.000.000:00000</string>
</property>
</widget>
<widget class="QPushButton" name="refreshAmbeList">
<property name="geometry">
@ -114,7 +117,7 @@
<normaloff>:/recycle.png</normaloff>:/recycle.png</iconset>
</property>
</widget>
<widget class="ButtonSwitch" name="removeAmbeDevice">
<widget class="QPushButton" name="removeAmbeDevice">
<property name="geometry">
<rect>
<x>280</x>
@ -147,17 +150,17 @@
<string>In use</string>
</property>
</widget>
<widget class="ButtonSwitch" name="importSerial">
<widget class="QPushButton" name="importSerial">
<property name="geometry">
<rect>
<x>110</x>
<x>120</x>
<y>250</y>
<width>24</width>
<height>23</height>
</rect>
</property>
<property name="toolTip">
<string>Use device</string>
<string>Use serial device</string>
</property>
<property name="text">
<string/>
@ -167,10 +170,10 @@
<normaloff>:/arrow_up.png</normaloff>:/arrow_up.png</iconset>
</property>
</widget>
<widget class="ButtonSwitch" name="importAddress">
<widget class="QPushButton" name="importAddress">
<property name="geometry">
<rect>
<x>110</x>
<x>120</x>
<y>60</y>
<width>24</width>
<height>23</height>
@ -197,7 +200,7 @@
</rect>
</property>
<property name="toolTip">
<string>Refresh list of devices and servers in use</string>
<string>Remove all devices</string>
</property>
<property name="text">
<string/>
@ -207,14 +210,40 @@
<normaloff>:/sweep.png</normaloff>:/sweep.png</iconset>
</property>
</widget>
<widget class="QLabel" name="statusText">
<property name="geometry">
<rect>
<x>10</x>
<y>420</y>
<width>291</width>
<height>19</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
<widget class="QPushButton" name="importAllSerial">
<property name="geometry">
<rect>
<x>150</x>
<y>250</y>
<width>24</width>
<height>23</height>
</rect>
</property>
<property name="toolTip">
<string>Use all serial devices</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/double_arrow_up.png</normaloff>:/double_arrow_up.png</iconset>
</property>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../resources/res.qrc"/>
</resources>

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 295 B

Wyświetl plik

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>double_arrow_up.png</file>
<file>no_film.png</file>
<file>gps.png</file>
<file>linear.png</file>