X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fdialogs%2Fconnect.cpp;h=af01b6cf6e47e6f07ae251b5104d90d7d3e6b599;hb=26f209b713171014a4f6dc3546b64bf691727cfd;hp=5baedcbcacaa1a2e06c52050419f5c77158b906d;hpb=3d79f521396c8e908fd237f5328153165099f5c3;p=pulseview.git diff --git a/pv/dialogs/connect.cpp b/pv/dialogs/connect.cpp index 5baedcb..af01b6c 100644 --- a/pv/dialogs/connect.cpp +++ b/pv/dialogs/connect.cpp @@ -22,6 +22,8 @@ #include +#include + #include "connect.hpp" #include @@ -47,13 +49,17 @@ namespace dialogs { Connect::Connect(QWidget *parent, pv::DeviceManager &device_manager) : QDialog(parent), + tcp_endpoint_(&form_), + tcp_endpoint_layout_(&tcp_endpoint_), + tcp_host_(&tcp_endpoint_), + tcp_port_(&tcp_endpoint_), device_manager_(device_manager), layout_(this), form_(this), form_layout_(&form_), drivers_(&form_), serial_devices_(&form_), - scan_button_(tr("&Scan for Devices"), this), + scan_button_(tr("&Scan for devices using driver above"), this), device_list_(this), button_box_(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this) @@ -73,6 +79,15 @@ Connect::Connect(QWidget *parent, pv::DeviceManager &device_manager) : form_layout_.addRow(tr("Serial &Port"), &serial_devices_); serial_devices_.setEditable(true); + tcp_host_.setPlaceholderText("192.168.1.100"); + tcp_endpoint_layout_.addWidget(&tcp_host_); + tcp_endpoint_layout_.addWidget(new QLabel(":")); + tcp_port_.setRange(1, 65535); + tcp_port_.setValue(5555); + tcp_endpoint_layout_.addWidget(&tcp_port_); + tcp_endpoint_layout_.setContentsMargins(0, 0, 0, 0); + form_layout_.addRow(tr("TCP &Endpoint"), &tcp_endpoint_); + unset_connection(); connect(&scan_button_, SIGNAL(pressed()), @@ -106,14 +121,14 @@ void Connect::populate_drivers() * @todo Add support for non-monotonic devices i.e. DMMs * and sensors. */ - bool supported_device = driver->config_check( - ConfigKey::LOGIC_ANALYZER, ConfigKey::DEVICE_OPTIONS) | - driver->config_check( - ConfigKey::OSCILLOSCOPE, ConfigKey::DEVICE_OPTIONS); + const auto keys = driver->config_keys(); + + bool supported_device = keys.count(ConfigKey::LOGIC_ANALYZER) | + keys.count(ConfigKey::OSCILLOSCOPE); if (supported_device) drivers_.addItem(QString("%1 (%2)").arg( - driver->long_name().c_str()).arg(name.c_str()), + driver->long_name().c_str(), name.c_str()), qVariantFromValue(driver)); } } @@ -123,7 +138,7 @@ void Connect::populate_serials(shared_ptr driver) serial_devices_.clear(); for (auto serial : device_manager_.context()->serials(driver)) serial_devices_.addItem(QString("%1 (%2)").arg( - serial.first.c_str()).arg(serial.second.c_str()), + serial.first.c_str(), serial.second.c_str()), QString::fromStdString(serial.first)); } @@ -132,6 +147,8 @@ void Connect::unset_connection() device_list_.clear(); serial_devices_.hide(); form_layout_.labelForField(&serial_devices_)->hide(); + tcp_endpoint_.hide(); + form_layout_.labelForField(&tcp_endpoint_)->hide(); button_box_.button(QDialogButtonBox::Ok)->setDisabled(true); } @@ -142,6 +159,14 @@ void Connect::set_serial_connection(shared_ptr driver) form_layout_.labelForField(&serial_devices_)->show(); } +void Connect::set_tcp_connection(shared_ptr driver) +{ + (void)driver; + + tcp_endpoint_.show(); + form_layout_.labelForField(&tcp_endpoint_)->show(); +} + void Connect::scan_pressed() { device_list_.clear(); @@ -169,11 +194,20 @@ void Connect::scan_pressed() serial.toUtf8().constData()); } + if (tcp_endpoint_.isVisible()) { + QString host = tcp_host_.text(); + QString port = tcp_port_.text(); + if(!host.isEmpty()) { + QString conn = QString("tcp-raw/%1/%2").arg(host, port); + drvopts[ConfigKey::CONN] = Variant::create( + conn.toUtf8().constData()); + } + } + const list< shared_ptr > devices = device_manager_.driver_scan(driver, drvopts); - for (shared_ptr device : devices) - { + for (shared_ptr device : devices) { assert(device); QString text = QString::fromStdString( @@ -198,8 +232,11 @@ void Connect::device_selected(int index) unset_connection(); - if (driver->config_check(ConfigKey::SERIALCOMM, ConfigKey::SCAN_OPTIONS)) + if (driver->scan_options().count(ConfigKey::SERIALCOMM)) set_serial_connection(driver); + + if (driver->name() == "rigol-ds") // NBNB + set_tcp_connection(driver); } } // namespace dialogs