/*! * \brief Thread loop processing messages received from module. * \note This function is called when interface is started. Once new data has arrived, module non-specific signals are emitted. * \note After that, virtual processPortData function is called, which processes module-specific data and emits signals. */ void Interface::run() { while(isRunning()) { //read data from module if(inputPort.read(receivedBottle)) { //process module-non-specific data if(receivedBottle.get(0).asString()=="gpuList") { processGpuList(); } else if(receivedBottle.get(0).asString()=="message") { printMessage(); } else if(receivedBottle.get(0).asString()=="status") { emit statusReceived(receivedBottle.get(1).asInt()); } else if(receivedBottle.get(0).asString()=="progress") { emit progressReceived(receivedBottle.get(1).asInt()); } //process module-specific data - this should be overridden by inheriting classes processPortData(); } else { qDebug(" - %s_gui(%i): leaving interface event loop", module->binary.toStdString().c_str(), module->instance); break; } } }
void ApcUpsMon::processResponse() { // Process a response. It could be // either a status or an events reponse. We // use a regular expression to determine if // the response starts with APC [...] and ends // with END APC [...], in which case we assume // it to be a status response. If not, it must // be an events response. Crude but works. QTextStream in(response); lastResponseTimestamp = time(NULL); // Update response timestamp m_errorString.clear(); // No errors QString ev = upsData.value("events"); upsData.clear(); // Clear status data upsData.insert("events", ev); QRegExp srx("^APC *:.*\nEND APC *:[^\n]+\n$"); if (srx.exactMatch(response)) { // If it has matched, it must be status data while (!in.atEnd()) { // Split the data in key/value pairs, // separated by the first colon found // in the line QString line = in.readLine(); int pos = line.indexOf(':'); if (pos>0) { QString key = line.left(pos).trimmed(); QString value = line.mid(pos+1).trimmed(); upsData.insert(key, value); } } emit statusReceived(); } else { QRegExp erx("^[A-Z][a-z]{2} [A-Z][a-z]{2} [0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [A-Z]+ [0-9]{4} .+$"); QStringList value; while (!in.atEnd()) { QString line = in.readLine(); // Let's check that it looks like an event line if (erx.exactMatch(line)) { value.append(line); } } upsData.insert("events", value.join("\n")); emit eventsReceived(); } response.clear(); }
void ProcessHandler::printProcessStatus() { QProcess::ProcessState state = myProcess->state(); QString status; if(state == 1) status = "Starting"; else if(state == 2) status = "Running"; else status = "Not Running"; qDebug() << status; emit statusReceived(status); if(state == 0) { myProcess->close(); } }
//! [0] Window::Window() { createActions(); createTrayIcon(); centralWidget = new PydioGui(this); connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked())); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); const QIcon& icon = QIcon(":/images/Pydio16.png"); trayIcon->setIcon(icon); setWindowIcon(icon); trayIcon->show(); running = false; context = nzmqt::createDefaultContext(this); context->start(); nzmqt::Subscriber* sub = new nzmqt::Subscriber(*context, "tcp://127.0.0.1:5556", "sync", this); connect(sub, SIGNAL(pingReceived(QList<QByteArray>)), SLOT(pingReceived(QList<QByteArray>))); // Start command. sub->start(); nzmqt::Subscriber* sub2 = new nzmqt::Subscriber(*context, "tcp://127.0.0.1:5556", "status", this); connect(sub2, SIGNAL(pingReceived(QList<QByteArray>)), SLOT(statusReceived(QList<QByteArray>))); // Start command. sub2->start(); /* nzmqt::Requester* req = new nzmqt::Requester(*context, "tcp://127.0.0.1:5557", "STATUS", this); connect(req, SIGNAL(replyReceived(QList<QByteArray>)), this, SLOT(statusReceived(QList<QByteArray>))); req->start(); */ setWindowTitle(tr("Systray")); resize(400, 300); }
//---------------------------------------------------------------------------- void ctkExampleDicomHost::notifyStatus(const ctkDicomAppHosting::Status& status) { qDebug()<< "new status received:"<<status.codeMeaning; emit statusReceived(status);; }
//! [6] //! [6] void Window::toggleJobStatus() { nzmqt::Requester* req = new nzmqt::Requester(*context, "tcp://127.0.0.1:5557", running?"PAUSE":"START", this); connect(req, SIGNAL(replyReceived(QList<QByteArray>)), this, SLOT(statusReceived(QList<QByteArray>))); req->start(); }