Exemplo n.º 1
0
void StreamlineSetup::handleRequest(char* xml) {
	mxml_node_t *tree, *node;
	const char * attr = NULL;

	tree = mxmlLoadString(NULL, xml, MXML_NO_CALLBACK);
	node = mxmlFindElement(tree, tree, TAG_REQUEST, ATTR_TYPE, NULL, MXML_DESCEND_FIRST);
	if (node) {
		attr = mxmlElementGetAttr(node, ATTR_TYPE);
	}
	if (attr && strcmp(attr, VALUE_EVENTS) == 0) {
		sendEvents();
		logg.logMessage("Sent events xml response");
	} else if (attr && strcmp(attr, VALUE_CONFIGURATION) == 0) {
		sendConfiguration();
		logg.logMessage("Sent configuration xml response");
	} else if (attr && strcmp(attr, VALUE_COUNTERS) == 0) {
		sendCounters();
		logg.logMessage("Sent counters xml response");
	} else if (attr && strcmp(attr, VALUE_CAPTURED) == 0) {
		CapturedXML capturedXML;
		char* capturedText = capturedXML.getXML(false);
		sendData(capturedText, strlen(capturedText), RESPONSE_XML);
		free(capturedText);
		logg.logMessage("Sent captured xml response");
	} else if (attr && strcmp(attr, VALUE_DEFAULTS) == 0) {
		sendDefaults();
		logg.logMessage("Sent default configuration xml response");
	} else {
		char error[] = "Unknown request";
		sendData(error, strlen(error), RESPONSE_NAK);
		logg.logMessage("Received unknown request:\n%s", xml);
	}

	mxmlDelete(tree);
}
Exemplo n.º 2
0
void Client::resize() {

    clientAreaRect_.copy(this);

    if (hasFrame_) {
        ostringstream oss;
        oss << "frame resize: x=" << x() << ", y=" << y() << ", w=" <<
            width() << ", h=" << height();
        LOGDEBUG(oss.str());
        XCORE->moveResize(frameWindow(), this);

        if (frame()) {
            // maximize client window
            clientAreaRect_.setX(0);
            clientAreaRect_.setY(0);
            clientAreaRect_.setWidth(width());
            clientAreaRect_.setHeight(height());
        }
        else {
            label_->setY(borderWidth_); // label fix for toggleBorder
            fitClientArea();
        }
    }
    XCORE->moveResize(clientWindow_, &clientAreaRect_);
    sendConfiguration();
    illuminate();
}
Exemplo n.º 3
0
void ConfigDialog::load()
{
    QSettings s;
    ui->comboChannel->setCurrentIndex(s.value("Transceiver/Channel", DEFAULT_TRANSCEIVER_CHANNEL).toUInt());
    ui->systemDelayBox->setValue(s.value("Tracking/SystemDelay", DEFAULT_SYSTEM_DELAY).toUInt()); // in ms

    ui->simVisionDelay->setValue(s.value("Simulator/VisionDelay", DEFAULT_SIM_VISION_DELAY).toUInt());
    ui->simProcessingTime->setValue(s.value("Simulator/ProcessingTime", DEFAULT_SIM_PROCESSING_TIME).toUInt());

    ui->visionPort->setValue(s.value("Amun/VisionPort", DEFAULT_VISION_PORT).toUInt());
    sendConfiguration();
}
Exemplo n.º 4
0
void ConfigDialog::apply()
{
    QSettings s;
    s.setValue("Transceiver/Channel", ui->comboChannel->currentIndex());
    s.setValue("Tracking/SystemDelay", ui->systemDelayBox->value());

    s.setValue("Simulator/VisionDelay", ui->simVisionDelay->value());
    s.setValue("Simulator/ProcessingTime", ui->simProcessingTime->value());

    s.setValue("Amun/VisionPort", ui->visionPort->value());

    sendConfiguration();
}
void Cooller_ModBusController::checkConnectionState(void)
{
    QList<QSerialPortInfo> a_info = QSerialPortInfo::availablePorts();

    if (a_info.empty())
    {
        m_configDialog->setError(QObject::tr("COM ports aren't available"), true);
        m_info.clear();
        m_configDialog->setCOMindex(-1);
        m_available = false;
        return;
    }
    
    if (a_info.size() != m_info.size() || ! std::equal(a_info.begin(), a_info.end(), m_info.begin(), equalPredicat))
    {
        int n = m_configDialog->getCOMindex();
        if (-1 != n)
        {
            QString currentPortName = m_info[n].portName();
            n = -1;
            for (int i = 0; i < a_info.size(); i++)
            {
                if (a_info[i].portName() == currentPortName)
                {
                    n = i;
                    break;
                }
            }
        }
       
        if (!m_available)
        {
            m_available = true;
            m_configDialog->clearError();
        }

        m_info = a_info;
        m_configDialog->setCOMlist(m_info);
        
        n = (-1 != n) ? n : 0;
        m_configDialog->setCOMindex(n);

        if (m_connector.isActive())
            sendConfiguration();
    }
}
Exemplo n.º 6
0
void SDRdaemonGui::updateWithStreamTime()
{
	if (m_initSendConfiguration)
	{
		sendConfiguration();
		m_initSendConfiguration = false;
	}

    quint64 startingTimeStampMsec = ((quint64) m_startingTimeStamp.tv_sec * 1000LL) + ((quint64) m_startingTimeStamp.tv_usec / 1000LL);
    QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
    QString s_date = dt.toString("yyyy-MM-dd  hh:mm:ss.zzz");
	ui->absTimeText->setText(s_date);

	if (m_syncLocked) {
		ui->streamLocked->setStyleSheet("QToolButton { background-color : green; }");
	} else {
		ui->streamLocked->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
	}

	QString s = QString::number(m_frameSize / 1024.0, 'f', 0);
	ui->frameSizeText->setText(tr("%1").arg(s));

	if (m_lz4) {
		ui->lz4Compressed->setStyleSheet("QToolButton { background-color : green; }");
	} else {
		ui->lz4Compressed->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
	}

	s = QString::number(m_compressionRatio, 'f', 2);
	ui->compressionRatioText->setText(tr("%1").arg(s));

	s = QString::number(m_nbLz4DataCRCOK, 'f', 0);
	ui->dataCRCOKText->setText(tr("%1").arg(s));

	s = QString::number(m_nbLz4SuccessfulDecodes, 'f', 0);
	ui->lz4DecodesOKText->setText(tr("%1").arg(s));

	s = QString::number(m_bufferLengthInSecs, 'f', 1);
	ui->bufferLenSecsText->setText(tr("%1").arg(s));

	s = QString::number((m_bufferGauge < 0 ? -50 - m_bufferGauge : 50 - m_bufferGauge), 'f', 0);
	ui->bufferRWBalanceText->setText(tr("%1").arg(s));

    ui->bufferGaugeNegative->setValue((m_bufferGauge < 0 ? 50 + m_bufferGauge : 0));
    ui->bufferGaugePositive->setValue((m_bufferGauge < 0 ? 0 : 50 - m_bufferGauge));
}
Exemplo n.º 7
0
//no checksum
void decodeClientInput(char* buf, int length) {
	switch (buf[0]) {
		case 'M':
			getMoistureReading(buf[1]);
			break;
		case 'D':
			setDryLevel(buf[1]);
			break;
		case 'C':
			assert(length == CONFIG_BLOCK_SIZE+1);
			sendConfiguration(buf);
			break;
		default:
			printf("ERROR: BAD COMMAND!\n");
			break;
	}
}
Cooller_ModBusController::Cooller_ModBusController(CoolerStateWidget *view, ModBusDialog *config) :
    m_view(view), 
    m_configDialog(config),
    m_recheckTimer(new QTimer(this)),
    m_available(false),
    m_comunicationSpeedIndex(6), //9600
    m_currentDeviceID(1),
    m_connector(this),
    m_externalManager(this),
    m_modbus(this)
{
    connect(m_recheckTimer, SIGNAL(timeout()), this, SLOT(updateState()));
    m_recheckTimer->setInterval(500);
    m_recheckTimer->start();
    config->setExternalCommunicator(&m_connector);

    connect(m_configDialog, SIGNAL(speedChanged(int)), this, SLOT(newSpeed(int)));
    connect(m_configDialog, SIGNAL(portChanged(int)), this, SLOT(newPort(int)));
    connect(m_configDialog, SIGNAL(deviceIDChanged(int)), this, SLOT(newDevice(int)));
    connect(&m_connector, SIGNAL(connectionEstablished()), config, SLOT(connectionEstablished()));
    connect(&m_connector, SIGNAL(connectionEstablished()), this, SLOT(sendConfiguration()));
    connect(&m_connector, SIGNAL(connectionBroken()), config, SLOT(connectionBroken()));
    connect(&m_connector, SIGNAL(connectionErrorOccured(QString)), config, SLOT(connectionErrorOccured(QString)));
    connect(&m_externalManager, SIGNAL(stateChanged()), this, SLOT(externalStateChanged()));
    connect(&m_externalManager, SIGNAL(listChanged()), this, SLOT(externalListChanged()));
    connect(&m_modbus, SIGNAL(deviceListUpdated(void)), this, SLOT(deviceObserverWaked()));

    QString configsPath = Configurator::getConfigFilesPath();
    QDirIterator iter(configsPath, QStringList() << "*.xml", QDir::Files | QDir::NoDotAndDotDot, QDirIterator::NoIteratorFlags);
    int configsRed = 0;
    while (iter.hasNext())
    {
        iter.next();
        QString xmlFilePath = iter.filePath();
        if (readXMLConfig(xmlFilePath))
            configsRed++;
    }
    if (0 == configsRed )
    {
        emit newStatus(tr("No config files were found"));
    }
}
Exemplo n.º 9
0
void Client::handleConfigureRequest(XConfigureRequestEvent *event) {

    XWindowChanges wc;

    if (event->value_mask & CWStackMode) {
        if (attached()) {
            if (!isFocused()) {
                requestsFocus_ = true;
            }
            if (monitor()->focused() != attached()) {
                attached()->setRequestsFocus(true);
            }
        }
        event->value_mask &= ~CWStackMode;
    }

    event->value_mask &= ~CWSibling;
    if (!frame()
#ifdef SLOT_SUPPORT
        || (mode_ == SLOT)
#endif
       ) {

        // floating client

        gravitate(true);

        if (event->value_mask & CWX) {
            setX(event->x);
        }
        if (event->value_mask & CWY) {
            setY(event->y);
        }
        if (event->value_mask & CWWidth) {
            setWidth(event->width);
        }
        if (event->value_mask & CWHeight) {
            setHeight(event->height);
        }
        if (event->value_mask & CWBorderWidth) {
            clientBorderWidth_ = event->border_width;
        }
        ostringstream oss;
        oss << "configure request: x=" << x() << ", y=" << y()
            << ", w=" << width() << ", h=" << height();
        LOGDEBUG(oss.str());

        gravitate(false);

        // applied patch by Dr. J. Pfefferl
        if (hasFrame_) {

            if((event->value_mask & CWWidth)) {
                setWidth(width() + 2 * borderWidth_);
            }
            if((event->value_mask & CWHeight)) {
                setHeight(height() + titleBarHeight_ + 2 * borderWidth_
                        + (titleBarHeight_ ? 1 : 0));
            }
            if((event->value_mask & CWX)) {
                setX(x() - borderWidth_);
            }
            if((event->value_mask & CWY)) {
                setY(y() - titleBarHeight_ - borderWidth_);
            }

            wc.x = x();
            wc.y = y();
            wc.width = width();
            wc.height = height();
            wc.border_width = 1; // event->border_width
            wc.sibling = None;
            wc.stack_mode = event->detail;
            XCORE->configureWindow(frameWindow(), event->value_mask, &wc);
            fitClientArea();
            sendConfiguration();
        }
        else {
            // save current dimensions to client area
            clientAreaRect_.copy(this);
        }
    }

#ifdef SLOT_SUPPORT
    if (mode_ == SLOT) {
        monitor()->slot()->manage();
    }
    else
#endif // SLOT_SUPPORT
    {
        // If client is attached to a frame, the clientAreaRect_ has
        // the size of the frames client area.
        wc.x = clientAreaRect_.x();
        wc.y = clientAreaRect_.y();
        wc.width = clientAreaRect_.width();
        wc.height = clientAreaRect_.height();
        wc.border_width = 0;
        wc.sibling = None;
        event->value_mask |= CWBorderWidth;

        XCORE->configureWindow(clientWindow_, event->value_mask, &wc);

        illuminate();
    }
}
Exemplo n.º 10
0
void SDRdaemonGui::on_sendButton_clicked(bool checked)
{
	sendConfiguration();
	ui->specificParms->setCursorPosition(0);
	ui->sendButton->setEnabled(false);
}