More verbose uotput in terminal

This commit is contained in:
santi 2014-07-02 18:33:47 +02:00
parent 45115830c0
commit 1d6a42a3aa
9 changed files with 38 additions and 150 deletions

0
lms-audio.xlm Executable file → Normal file
View file

View file

@ -53,8 +53,6 @@ bool AudioMotor::init()
connect(m_writePD, SIGNAL(connected()),this, SLOT(newConexion())); connect(m_writePD, SIGNAL(connected()),this, SLOT(newConexion()));
connect(m_writePD, SIGNAL(error(QAbstractSocket::SocketError)) , this, SLOT(errorWrite(QAbstractSocket::SocketError))); connect(m_writePD, SIGNAL(error(QAbstractSocket::SocketError)) , this, SLOT(errorWrite(QAbstractSocket::SocketError)));
// Servidor para recibir feedback de Pure Data // Servidor para recibir feedback de Pure Data
m_readPD = new QTcpServer(this); m_readPD = new QTcpServer(this);
Q_CHECK_PTR(m_readPD); Q_CHECK_PTR(m_readPD);
@ -64,6 +62,7 @@ bool AudioMotor::init()
qDebug(QString("AudioMotor| Listening to PD on TCP port %1").arg(PDPORT).toLatin1()); qDebug(QString("AudioMotor| Listening to PD on TCP port %1").arg(PDPORT).toLatin1());
} else { } else {
qErrnoWarning(QString("AudioMotor::init() can not init TCP Server on port %1").arg(PDPORT).toLatin1()); qErrnoWarning(QString("AudioMotor::init() can not init TCP Server on port %1").arg(PDPORT).toLatin1());
emit toTerminal(QString("AudioMotor::init() can not init TCP Server on port)" + PDPORT));
} }
// Start the pd process an set up PD // Start the pd process an set up PD
@ -77,16 +76,14 @@ bool AudioMotor::init()
arguments.append("./puredata/pd -channels 2 -stderr -nostdpath -path ./puredata/externals/ -open ./puredata/lms-audio.pd "); arguments.append("./puredata/pd -channels 2 -stderr -nostdpath -path ./puredata/externals/ -open ./puredata/lms-audio.pd ");
if (!m_gui) if (!m_gui)
arguments.append("-nogui"); arguments.append("-nogui");
qDebug() << "PD starts with arguments: " << arguments;
m_pd_audio->start(arguments); m_pd_audio->start(arguments);
if (m_pd_audio->waitForStarted(3000)){ if (m_pd_audio->waitForStarted(3000)){
qDebug("AudioMotor| PD started."); qDebug("AudioMotor| PD started");
emit toTerminal(QString("AudioMotor| PD started"));
} }
else else
{ {
qWarning("AudioMotor| PD not started!"); emit toTerminal("AudioMotor| Can not init PD");
qErrnoWarning("AudioMotor| Can not init PD"); qErrnoWarning("AudioMotor| Can not init PD");
return false; return false;
} }
@ -154,11 +151,13 @@ bool AudioMotor::load(int layer, QString file)
if (QAbstractSocket::ConnectedState != m_writePD->state()) if (QAbstractSocket::ConnectedState != m_writePD->state())
{ {
qErrnoWarning("AudioMotor::load(): Socket not conected: "); qErrnoWarning("AudioMotor::load(): Socket not conected: ");
emit toTerminal("AudioMotor::load(): Socket not connectedt");
return false; return false;
} }
if (message.size() != m_writePD->write(message.toAscii().constData(), message.size())) if (message.size() != m_writePD->write(message.toAscii().constData(), message.size()))
{ {
qErrnoWarning("AudioMotor::load(): Can not write to socket"); qErrnoWarning("AudioMotor::load(): Can not write to socket");
emit toTerminal("AudioMotor::load(): Can not write to socket");
return false; return false;
} }
return true; return true;
@ -293,6 +292,7 @@ void AudioMotor::newMessage()
if (m_connectedSocket == NULL) if (m_connectedSocket == NULL)
{ {
qDebug()<<("AudioMotor::newMessage() Socket not connected. Trying open it..."); qDebug()<<("AudioMotor::newMessage() Socket not connected. Trying open it...");
emit toTerminal("AudioMotor::newMessage() Socket not connected. Trying open it...");
newPeer(); newPeer();
return; return;
} }
@ -302,7 +302,6 @@ void AudioMotor::newMessage()
void AudioMotor::parse(QString message) void AudioMotor::parse(QString message)
{ {
int aux;
QStringList list = message.split("\n", QString::SkipEmptyParts); QStringList list = message.split("\n", QString::SkipEmptyParts);
for (int i = 0; i < list.size(); i ++) { for (int i = 0; i < list.size(); i ++) {
if (list.at(i).size() > 0) { if (list.at(i).size() > 0) {
@ -310,7 +309,8 @@ void AudioMotor::parse(QString message)
QChar val = list.at(i).at(0); QChar val = list.at(i).at(0);
switch (val.digitValue()) { switch (val.digitValue()) {
case 0: case 0:
qDebug() << "AudioMotor::newMessage() Loadbang from PD Audio received..."; qDebug() << "AudioMotor::newMessage() Loadbang from PD Audio received";
emit toTerminal("AudioMotor::newMessage() Loadbang from PD Audio received");
// Conectamos a Pure Data para escribir // Conectamos a Pure Data para escribir
m_writePD->connectToHost(QHostAddress::LocalHost, SOCKET, QIODevice::WriteOnly); m_writePD->connectToHost(QHostAddress::LocalHost, SOCKET, QIODevice::WriteOnly);
if (m_writePD->waitForConnected(30000)) if (m_writePD->waitForConnected(30000))
@ -334,10 +334,6 @@ void AudioMotor::parse(QString message)
break; break;
} }
} }
} }
} }
@ -351,6 +347,7 @@ void AudioMotor::errorWrite(QAbstractSocket::SocketError error)
// QString error = m_writePD->errorString(); // QString error = m_writePD->errorString();
qErrnoWarning(QString("AudioMotor::errorWrite() %1").arg(error).toLatin1()); qErrnoWarning(QString("AudioMotor::errorWrite() %1").arg(error).toLatin1());
emit toTerminal(QString("AudioMotor::errorWrite() ") + error);
} }
/** Sends packets to Pure Data audio /** Sends packets to Pure Data audio
@ -376,5 +373,6 @@ bool AudioMotor::sendPacket(const char *buffer, int bufferLen)
// Function error sending packets to PD audio // Function error sending packets to PD audio
void AudioMotor::errorSending() { void AudioMotor::errorSending() {
qDebug() << "AudioMotor| Can not send packets to PD"; qDebug() << "AudioMotor| Can not send packets to PD";
emit toTerminal("AudioMotor| Can not send packets to PD");
} }

View file

@ -114,6 +114,7 @@ signals:
void newConnection(); void newConnection();
void mediaLoaded(int layer, QString folder, QString file); void mediaLoaded(int layer, QString folder, QString file);
void volChanged(int layer, int vol); void volChanged(int layer, int vol);
void toTerminal(QString message);
private slots: private slots:

View file

@ -25,8 +25,6 @@
libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent) libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
{ {
ola = new olaThread();
qDebug() << "********************************************************************************"; qDebug() << "********************************************************************************";
qDebug() << QDate::currentDate() << QTime::currentTime(); qDebug() << QDate::currentDate() << QTime::currentTime();
qDebug() << VERSION; qDebug() << VERSION;
@ -36,13 +34,7 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
// Inicia el User Interface // Inicia el User Interface
ui.setupUi(this); ui.setupUi(this);
// Inicia la lectura de dmx a través de ola
ola->start(QThread::TimeCriticalPriority );
ola->blockSignals(true);
// Inicia el widget Terminal // Inicia el widget Terminal
textEdit = new QTextEdit(this); textEdit = new QTextEdit(this);
textEdit->append(QString::fromAscii(VERSION)); textEdit->append(QString::fromAscii(VERSION));
textEdit->append(QString::fromAscii(LICENSE)); textEdit->append(QString::fromAscii(LICENSE));
@ -53,6 +45,14 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
bottomWidget->setWidget(textEdit); bottomWidget->setWidget(textEdit);
addDockWidget(Qt::BottomDockWidgetArea, bottomWidget); addDockWidget(Qt::BottomDockWidgetArea, bottomWidget);
// Inicia la lectura de dmx a través de ola
ola = new olaThread();
Q_CHECK_PTR(ola);
connect(ola, SIGNAL(toTerminal(QString)),
this, SLOT(toTerminal(QString)));
ola->start(QThread::TimeCriticalPriority );
ola->blockSignals(true);
// Inicia el widget central de audio // Inicia el widget central de audio
aw = new AudioWidget(this); aw = new AudioWidget(this);
@ -74,6 +74,9 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
textEdit->append("Pure Data GUI's will be shown"); textEdit->append("Pure Data GUI's will be shown");
} else { AudioMotor::getInstance()->setGui(false); } } else { AudioMotor::getInstance()->setGui(false); }
connect(AudioMotor::getInstance(), SIGNAL(toTerminal(QString)),
this, SLOT(toTerminal(QString)));
if (args.contains("-log")) if (args.contains("-log"))
{ {
textEdit->append("Log to file"); textEdit->append("Log to file");
@ -184,7 +187,7 @@ void libreMediaServerAudio::olasetup()
} }
/** /**
* Parse the nes dmx information * Parse the dmx information
*/ */
void libreMediaServerAudio::dmxInput(int layer, int channel, int value) void libreMediaServerAudio::dmxInput(int layer, int channel, int value)
{ {

View file

@ -48,7 +48,7 @@
#define LICENSE "GPL 3 License. See LICENSE.txt and credits.txt for details" #define LICENSE "GPL 3 License. See LICENSE.txt and credits.txt for details"
class QMenu; class QMenu;
class QProcess; //class QProcess;
class libreMediaServerAudio : public QMainWindow class libreMediaServerAudio : public QMainWindow
{ {
@ -86,6 +86,11 @@ private:
public slots: public slots:
inline void toTerminal (QString message)
{
textEdit->append(message);
}
private slots: private slots:
/** /**

View file

@ -1,51 +0,0 @@
/* olainterface.cpp
Santi Noreña 2013
It includes two classes:
olaWorker is the threading class that reads raw DMX from ola daemon and save it into a buffer ordered in layers
olaInterface controls olaWorker and translates DMX values received from olaWorker into orders to RenderingManager and Source
*/
#include "olainterface.h"
olaInterface::olaInterface()
{
qDebug() << tr("olaInterface|") << "Starting";
m_thread = NULL;
m_thread = new QThread;
Q_CHECK_PTR(m_thread);
worker = new olaWorker();
Q_CHECK_PTR(worker);
connect (worker, SIGNAL(dmx(int,int,int)), this, SLOT(dmx(int,int,int)), Qt::QueuedConnection); // The DMX values.
worker->moveToThread(m_thread);
connect(m_thread, SIGNAL(started()), worker, SLOT(olastart()));
connect(m_thread, SIGNAL(finished()), m_thread, SLOT(deleteLater()));
m_thread->start();
}
olaInterface::~olaInterface()
{
close();
}
// Close olaWorker and finish the thread
void olaInterface::close()
{
worker->blockSignals(true);
worker->olastop();
delete worker;
}
////////////////////////////////////////////////////////////
//
// Parse new DMX
//
////////////////////////////////////////////////////////////
//New dmx. Connected with signal newdmx from olaInterface->Worker
void olaInterface::dmx(int layer, int channel, int value)
{
}

View file

@ -1,68 +0,0 @@
/* olainterface.h
Santi Noreña 2013
It includes two classes:
olaWorker is the threading class that reads raw DMX from ola daemon
olaInterface controls olaWorker and translates DMX values received from olaWorker into orders to RenderingManager and Source
*/
#ifndef OLAINTERFACE_H
#define OLAINTERFACE_H
//#define DMX_SOURCETYPE 7
#define LAYER_CHANNELS 15 // The numer of control channels per video layer
#define MAX_SOURCE_DMX 8 // Number of maximum Sources controlled by DMX. It should be equal to MAX_SOURCE_COUNT
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <QObject>
#include <QDebug>
#include <QXmlStreamReader>
#include <QFile>
#include <QMessageBox>
#include <QProcess>
// The OLA Library
#include <ola/OlaClientWrapper.h>
#include <ola/OlaCallbackClient.h>
//#include <ola/OlaClient.h>
#include "libremediaserver.h"
using namespace ola;
class olaInterface : public QObject
{
Q_OBJECT
public:
explicit olaInterface();
virtual ~olaInterface();
void open(); // Starts the thread and open the connection with olad
void close(); // Close the connection with olad
olaWorker *worker; // The thread of connection with ola.
protected:
QThread *m_thread; // The thread for olaWorker
private:
void readDataFromXML(); // Read the DMX configuration from the file dmx.xml
public slots:
void dmx(int layer, int channel, int value); // Connected with signal dmx from olaWorker. This is the horsepower of all this. Converts DMX orders
// into orders to RenderingManager and Source. Mantains updated the videolayer struct.
signals:
};
#endif // OLAINTERFACE_H

View file

@ -51,8 +51,9 @@ void olaThread::run() {
if (!m_client->RegisterUniverse(m_universe, ola::REGISTER,ola::NewSingleCallback(&RegisterComplete))) { if (!m_client->RegisterUniverse(m_universe, ola::REGISTER,ola::NewSingleCallback(&RegisterComplete))) {
qDebug() << "Can not register universe %1".arg(m_universe); qDebug() << "Can not register universe %1".arg(m_universe);
}*/ }*/
qDebug() << tr("olaThread| Running");
emit toTerminal("Reading DMX");
m_clientWrapper->GetSelectServer()->Run(); m_clientWrapper->GetSelectServer()->Run();
qDebug()<< tr("olaThread|") << "Running";
} }
void olaThread::stop() void olaThread::stop()
@ -111,19 +112,18 @@ bool olaThread::CheckDataLoss() {
if (diff.tv_sec > 4 || (diff.tv_sec == 4 && diff.tv_usec > 4000000)) { if (diff.tv_sec > 4 || (diff.tv_sec == 4 && diff.tv_usec > 4000000)) {
// loss of data // loss of data
qDebug()<< "olaThread| Can not read one or several universes"; qDebug()<< "olaThread| Can not read one or several universes";
emit toTerminal("Can not read one universe");
// return false; // Retorna false para deshabilitar el callback // return false; // Retorna false para deshabilitar el callback
} }
} }
return true; return true;
} }
void olaThread::setLayersNumber(int layersNumber) { m_layersNumber = layersNumber; } void olaThread::setLayersNumber(int layersNumber) { m_layersNumber = layersNumber; }
void olaThread::resendDmx() void olaThread::resendDmx()
{ {
emit toTerminal("Resending DMX info");
for (int i = 0; i < m_layersNumber; i++) { // loop for reading the channels by layer. for (int i = 0; i < m_layersNumber; i++) { // loop for reading the channels by layer.
for (int j = 0; j < LAYER_CHANNELS; j++){ for (int j = 0; j < LAYER_CHANNELS; j++){
emit dmxOutput(i, j, m_dmx[i][j]); // Connected with dmx slot in olaInterface. emit dmxOutput(i, j, m_dmx[i][j]); // Connected with dmx slot in olaInterface.

View file

@ -34,8 +34,6 @@ public:
olaThread(QObject *parent = 0); olaThread(QObject *parent = 0);
virtual ~olaThread(); virtual ~olaThread();
/** Retorna el valor de un canal /** Retorna el valor de un canal
*@param int layer the layer for we want the channel *@param int layer the layer for we want the channel
*@param int channel the channel for the value wanted *@param int channel the channel for the value wanted
@ -54,7 +52,6 @@ public:
private: private:
void run (); void run ();
ola::client::OlaClientWrapper *m_clientWrapper; ola::client::OlaClientWrapper *m_clientWrapper;
@ -87,8 +84,10 @@ private:
inline void RegisterComplete(const ola::client::Result &error) { inline void RegisterComplete(const ola::client::Result &error) {
if (error.Success()) { if (error.Success()) {
qDebug() << "Register Universe success"; qDebug() << "Register Universe success";
emit toTerminal("Register Universe success");
} else { } else {
qWarning() << "olaThread|" << "Register command failed" << QString::fromStdString(error.Error()); qWarning() << "olaThread|" << "Register command failed" << QString::fromStdString(error.Error());
emit toTerminal("olaThread| Register command failed " + QString::fromStdString(error.Error()));
} }
} }
@ -121,6 +120,7 @@ signals:
void finished(); // Signal for closing. Not used now. void finished(); // Signal for closing. Not used now.
void dmxOutput(int layer, int channel, int value); // Signal when a channel has changed void dmxOutput(int layer, int channel, int value); // Signal when a channel has changed
void toTerminal(QString message);
}; };
#endif // OLATHREAD_H #endif // OLATHREAD_H