SBI_NetworkIconDialog::SBI_NetworkIconDialog(QWidget* parent)
    : QDialog(parent)
    , ui(new Ui::SBI_NetworkIconDialog)
{
    setAttribute(Qt::WA_DeleteOnClose);

    ui->setupUi(this);

    ui->addButton->setIcon(QIcon::fromTheme("document-new", QIcon(":sbi/data/add.png")));
    ui->removeButton->setIcon(QIcon::fromTheme("edit-delete", QIcon(":sbi/data/remove.png")));

    const QHash<QString, SBI_NetworkProxy*> &proxies = SBINetManager->proxies();

    QHashIterator<QString, SBI_NetworkProxy*> it(proxies);
    while (it.hasNext()) {
        it.next();
        ui->comboBox->addItem(it.key());
    }

    updateWidgets();
    showProxy(ui->comboBox->currentText());

    connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addProxy()));
    connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(removeProxy()));
    connect(ui->comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(showProxy(QString)));
    connect(ui->proxyButtonBox, SIGNAL(accepted()), this, SLOT(saveProxy()));
    connect(ui->closeButton, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close()));
}
/**
 * Check if the device factory or proxy factory can handle the element.
 */
bool InputManager::configureProxy(jccl::ConfigElementPtr element)
{
   std::string proxy_name = element->getFullName();

vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL,
                                 std::string("gadget::InputManager::configureProxy: Named: ") + proxy_name + std::string("\n"),
                                 std::string("done configuring proxy\n"));

   Proxy* new_proxy;

   // Tell the factory to load the proxy
   // NOTE: The config for the proxy registers it with the input manager
   new_proxy = ProxyFactory::instance()->loadProxy(element);

   // Check for success
   if(NULL == new_proxy)
   {
      vprDEBUG(vprDBG_ERROR,vprDBG_CRITICAL_LVL)
         << clrOutNORM(clrRED,"ERROR:")
         << " gadget::InputManager::configureProxy: Proxy construction failed:"
         << proxy_name << std::endl << vprDEBUG_FLUSH;
      return false;
   }
   vprASSERT(proxy_name == new_proxy->getName());

   // -- Add to proxy table
   if(false == addProxy(new_proxy))
   {
      return false;
   }

   return true;
}
Esempio n. 3
0
 virtual void add(std::string key, std::unique_ptr<R> renderable)
 {
     addProxy(key, renderable.get());
 }
Esempio n. 4
0
MainWindow::MainWindow(Configuration *config, QWidget *parent)
    : QDialog(parent)
{
    this->config = config;
    QLabel *machineLabel = new QLabel("Machine:", this);
    machine = new ComboBox(this);
    machine->setFocusPolicy(Qt::NoFocus);
    machine->addItems(config->getMachTypeList());
    machine->setCurrentIndex(config->getMachType());

#ifndef __arm__
    quitButton = new QPushButton(tr("&Quit"), this);
    quitButton->setDisabled(true);
    connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
#endif

    resetButton = new QPushButton("&Reset", this);

    QStringList iplist = config->getHostAddress().split(".");

    QLabel *ipAddrLabel = new QLabel("IP Address:", this);
    ipAddr0 = new SpinBox(this);
    ipAddr0->setRange(127, 254);
    ipAddr0->setValue(iplist[0].toInt());
    ipAddr1 = new SpinBox(this);
    ipAddr1->setRange(0, 254);
    ipAddr1->setValue(iplist[1].toInt());
    ipAddr2 = new SpinBox(this);
    ipAddr2->setRange(0, 254);
    ipAddr2->setValue(iplist[2].toInt());
    ipAddr3 = new SpinBox(this);
    ipAddr3->setRange(220, 250);
    ipAddr3->setValue(iplist[3].toInt());

    QHBoxLayout *ipAddrLayout = new QHBoxLayout;
    ipAddrLayout->setSpacing(0);
    ipAddrLayout->addWidget(ipAddr0);
    ipAddrLayout->addWidget(ipAddr1);
    ipAddrLayout->addWidget(ipAddr2);
    ipAddrLayout->addWidget(ipAddr3);

#if 0
    QStringList maclist = config->getMacEther().split(":");

    QLabel *macAddrLabel = new QLabel("MAC Address:");
    macAddr0 = new SpinBox(this);
    macAddr0->setRange(0, 99);
    macAddr0->setValue(maclist[0].toInt());
    macAddr1 = new SpinBox(this);
    macAddr1->setRange(0, 99);
    macAddr1->setValue(maclist[1].toInt());
    macAddr2 = new SpinBox(this);
    macAddr2->setRange(0, 99);
    macAddr2->setValue(maclist[2].toInt());
    macAddr3 = new SpinBox(this);
    macAddr3->setRange(0, 99);
    macAddr3->setValue(maclist[3].toInt());
    macAddr4 = new SpinBox(this);
    macAddr4->setRange(0, 99);
    macAddr4->setValue(maclist[4].toInt());
    macAddr5 = new SpinBox(this);
    macAddr5->setRange(0, 99);
    macAddr5->setValue(maclist[5].toInt());

    QHBoxLayout *macAddrLayout = new QHBoxLayout();
    macAddrLayout->setSpacing(0);
    macAddrLayout->addWidget(macAddr0);
    macAddrLayout->addWidget(macAddr1);
    macAddrLayout->addWidget(macAddr2);
    macAddrLayout->addWidget(macAddr3);
    macAddrLayout->addWidget(macAddr4);
    macAddrLayout->addWidget(macAddr5);
#endif

    applyButton = new QPushButton("&Apply", this);
    connect(applyButton, SIGNAL(clicked()), this, SLOT(apply()));

    tableWidget = new QTableWidget(0, 7, this);
    tableWidget->setFocusPolicy(Qt::NoFocus);
    tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
    tableWidget->setAlternatingRowColors(true);
    tableWidget->setHorizontalHeaderLabels(
            QStringList() << tr("Device")
                          << tr("Baudrate")
                          << tr("Total Received")
                          << tr("Total Sent")
                          << tr("Receiving")
                          << tr("Sending")
                          << tr("Status"));

    deviceDescription = new QTableWidget(0, 2, this);
    deviceDescription->setFocusPolicy(Qt::NoFocus);
    deviceDescription->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
    deviceDescription->setAlternatingRowColors(true);
    deviceDescription->setHorizontalHeaderLabels(
            QStringList() << tr("Device")
                          << tr("Description"));
    deviceDescription->setColumnWidth(0, 200);

#ifdef __arm__
    if (config->getMachType() == MACH_VITAS) {
        addProxy(&consolePort, "/dev/ttySAC0", BAUD115200, 0, "Console");
        addProxy(&module0Port, "/dev/ttySAC1", BAUD115200, 1, "Standard parameters of the module");
        addProxy(&printerPort, "/dev/ttySAC2", BAUD38400, 2, "Printer");
        addProxy(&module1Port, "/dev/ttySAC3", BAUD19200, 3, "CO2 module");
        addProxy(&systemPort, "/dev/ttySYS", BAUD4800, 4, "System board");
    } else if (config->getMachType() == MACH_G60_COMMON) {
        addProxy(&consolePort, "/dev/ttySAC0", BAUD115200, 0, "Console");
        addProxy(&module0Port, "/dev/ttySAC1", BAUD500000, 1, "Built-in plug-in cage");
        addProxy(&printerPort, "/dev/ttySAC2", BAUD38400, 2, "Printer");
        addProxy(&module1Port, "/dev/ttySAC3", BAUD500000, 3, "External plug-in cage");
        addProxy(&systemPort, "/dev/ttyS0", BAUD4800, 4, "System board");
        addProxy(&tsPort, "/dev/ttyS1", BAUD9600, 5, "Touchscreen");
    } else if (config->getMachType() == MACH_G60_SFDA) {
        addProxy(&consolePort, "/dev/ttySAC0", BAUD115200, 0, "Console");
        addProxy(&systemPort, "/dev/ttySAC1", BAUD4800, 1, "System board");
        addProxy(&printerPort, "/dev/ttySAC2", BAUD38400, 2, "Printer");
        addProxy(&tsPort, "/dev/ttySAC3", BAUD9600, 3, "Touchscreen");
        addProxy(&module0Port, "/dev/ttySS0", BAUD500000, 4, "Built-in plug-in cage");
        addProxy(&module1Port, "/dev/ttySS1", BAUD500000, 5, "Built-in plug-in cage");
        tableWidget->hideRow(5);
        deviceDescription->hideRow(5);
        addProxy(&module2Port, "/dev/ttySS2", BAUD500000, 6, "External plug-in cage");
        addProxy(&module3Port, "/dev/ttySS3", BAUD500000, 7, "External plug-in cage");
    }
#else
    addProxy(&consolePort, "/dev/ttySAC0", BAUD115200, 0, "Console");
    addProxy(&systemPort, "/dev/ttySAC1", BAUD4800, 1, "System board");
    addProxy(&printerPort, "/dev/ttySAC2", BAUD38400, 2, "Printer");
    addProxy(&tsPort, "/dev/ttySAC3", BAUD9600, 3, "Touchscreen");
    addProxy(&module0Port, "/dev/ttySS0", BAUD500000, 4, "Built-in plug-in cage");
    addProxy(&module1Port, "/dev/ttySS1", BAUD500000, 5, "Built-in plug-in cage");
    tableWidget->hideRow(5);
    deviceDescription->hideRow(5);
    addProxy(&module2Port, "/dev/ttySS2", BAUD500000, 6, "External plug-in cage");
    addProxy(&module3Port, "/dev/ttySS3", BAUD500000, 7, "External plug-in cage");
#endif

    statusBar = new QStatusBar(this);
    statusBar->showMessage("Proxy server is starting ...");

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(machineLabel, 0, 0);
    mainLayout->addWidget(machine, 0, 1);
#ifndef __arm__
    mainLayout->addWidget(quitButton, 0, 7);
#endif
    mainLayout->addWidget(ipAddrLabel, 1, 0);
    mainLayout->addLayout(ipAddrLayout, 1, 1, 1, 2);
#if 0
    mainLayout->addWidget(macAddrLabel, 2, 0);
    mainLayout->addLayout(macAddrLayout, 2, 1, 1, 2);
    mainLayout->addWidget(applyButton, 2, 3);
    mainLayout->addWidget(resetButton, 2, 7);
#else
    mainLayout->addWidget(applyButton, 1, 3);
    mainLayout->addWidget(resetButton, 1, 7);
#endif
    mainLayout->addWidget(tableWidget, 3, 0, 1, 8);
    mainLayout->addWidget(deviceDescription, 4, 0, 1, 8);
    mainLayout->addWidget(statusBar, 5, 0, 1, 8);
    setLayout(mainLayout);
    loadStyleSheet("default");
    // loadStyleSheet("suresign");
}