More verbose uotput in terminal
This commit is contained in:
parent
45115830c0
commit
1d6a42a3aa
9 changed files with 38 additions and 150 deletions
0
lms-audio.xlm
Executable file → Normal file
0
lms-audio.xlm
Executable file → Normal file
|
@ -53,8 +53,6 @@ bool AudioMotor::init()
|
|||
connect(m_writePD, SIGNAL(connected()),this, SLOT(newConexion()));
|
||||
connect(m_writePD, SIGNAL(error(QAbstractSocket::SocketError)) , this, SLOT(errorWrite(QAbstractSocket::SocketError)));
|
||||
|
||||
|
||||
|
||||
// Servidor para recibir feedback de Pure Data
|
||||
m_readPD = new QTcpServer(this);
|
||||
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());
|
||||
} else {
|
||||
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
|
||||
|
@ -77,16 +76,14 @@ bool AudioMotor::init()
|
|||
arguments.append("./puredata/pd -channels 2 -stderr -nostdpath -path ./puredata/externals/ -open ./puredata/lms-audio.pd ");
|
||||
if (!m_gui)
|
||||
arguments.append("-nogui");
|
||||
qDebug() << "PD starts with arguments: " << arguments;
|
||||
|
||||
m_pd_audio->start(arguments);
|
||||
|
||||
if (m_pd_audio->waitForStarted(3000)){
|
||||
qDebug("AudioMotor| PD started.");
|
||||
qDebug("AudioMotor| PD started");
|
||||
emit toTerminal(QString("AudioMotor| PD started"));
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("AudioMotor| PD not started!");
|
||||
emit toTerminal("AudioMotor| Can not init PD");
|
||||
qErrnoWarning("AudioMotor| Can not init PD");
|
||||
return false;
|
||||
}
|
||||
|
@ -154,11 +151,13 @@ bool AudioMotor::load(int layer, QString file)
|
|||
if (QAbstractSocket::ConnectedState != m_writePD->state())
|
||||
{
|
||||
qErrnoWarning("AudioMotor::load(): Socket not conected: ");
|
||||
emit toTerminal("AudioMotor::load(): Socket not connectedt");
|
||||
return false;
|
||||
}
|
||||
if (message.size() != m_writePD->write(message.toAscii().constData(), message.size()))
|
||||
{
|
||||
qErrnoWarning("AudioMotor::load(): Can not write to socket");
|
||||
emit toTerminal("AudioMotor::load(): Can not write to socket");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -293,6 +292,7 @@ void AudioMotor::newMessage()
|
|||
if (m_connectedSocket == NULL)
|
||||
{
|
||||
qDebug()<<("AudioMotor::newMessage() Socket not connected. Trying open it...");
|
||||
emit toTerminal("AudioMotor::newMessage() Socket not connected. Trying open it...");
|
||||
newPeer();
|
||||
return;
|
||||
}
|
||||
|
@ -302,7 +302,6 @@ void AudioMotor::newMessage()
|
|||
|
||||
void AudioMotor::parse(QString message)
|
||||
{
|
||||
int aux;
|
||||
QStringList list = message.split("\n", QString::SkipEmptyParts);
|
||||
for (int i = 0; i < list.size(); i ++) {
|
||||
if (list.at(i).size() > 0) {
|
||||
|
@ -310,7 +309,8 @@ void AudioMotor::parse(QString message)
|
|||
QChar val = list.at(i).at(0);
|
||||
switch (val.digitValue()) {
|
||||
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
|
||||
m_writePD->connectToHost(QHostAddress::LocalHost, SOCKET, QIODevice::WriteOnly);
|
||||
if (m_writePD->waitForConnected(30000))
|
||||
|
@ -334,10 +334,6 @@ void AudioMotor::parse(QString message)
|
|||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -351,6 +347,7 @@ void AudioMotor::errorWrite(QAbstractSocket::SocketError error)
|
|||
// QString error = m_writePD->errorString();
|
||||
|
||||
qErrnoWarning(QString("AudioMotor::errorWrite() %1").arg(error).toLatin1());
|
||||
emit toTerminal(QString("AudioMotor::errorWrite() ") + error);
|
||||
}
|
||||
|
||||
/** 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
|
||||
void AudioMotor::errorSending() {
|
||||
qDebug() << "AudioMotor| Can not send packets to PD";
|
||||
emit toTerminal("AudioMotor| Can not send packets to PD");
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ signals:
|
|||
void newConnection();
|
||||
void mediaLoaded(int layer, QString folder, QString file);
|
||||
void volChanged(int layer, int vol);
|
||||
void toTerminal(QString message);
|
||||
|
||||
private slots:
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
ola = new olaThread();
|
||||
|
||||
qDebug() << "********************************************************************************";
|
||||
qDebug() << QDate::currentDate() << QTime::currentTime();
|
||||
qDebug() << VERSION;
|
||||
|
@ -36,13 +34,7 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
|||
// Inicia el User Interface
|
||||
ui.setupUi(this);
|
||||
|
||||
// Inicia la lectura de dmx a través de ola
|
||||
|
||||
ola->start(QThread::TimeCriticalPriority );
|
||||
ola->blockSignals(true);
|
||||
|
||||
// Inicia el widget Terminal
|
||||
|
||||
textEdit = new QTextEdit(this);
|
||||
textEdit->append(QString::fromAscii(VERSION));
|
||||
textEdit->append(QString::fromAscii(LICENSE));
|
||||
|
@ -53,6 +45,14 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
|||
bottomWidget->setWidget(textEdit);
|
||||
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
|
||||
|
||||
aw = new AudioWidget(this);
|
||||
|
@ -74,6 +74,9 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
|||
textEdit->append("Pure Data GUI's will be shown");
|
||||
} else { AudioMotor::getInstance()->setGui(false); }
|
||||
|
||||
connect(AudioMotor::getInstance(), SIGNAL(toTerminal(QString)),
|
||||
this, SLOT(toTerminal(QString)));
|
||||
|
||||
if (args.contains("-log"))
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#define LICENSE "GPL 3 License. See LICENSE.txt and credits.txt for details"
|
||||
|
||||
class QMenu;
|
||||
class QProcess;
|
||||
//class QProcess;
|
||||
|
||||
class libreMediaServerAudio : public QMainWindow
|
||||
{
|
||||
|
@ -86,6 +86,11 @@ private:
|
|||
|
||||
public slots:
|
||||
|
||||
inline void toTerminal (QString message)
|
||||
{
|
||||
textEdit->append(message);
|
||||
}
|
||||
|
||||
private slots:
|
||||
|
||||
/**
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -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
|
||||
|
|
@ -51,8 +51,9 @@ void olaThread::run() {
|
|||
if (!m_client->RegisterUniverse(m_universe, ola::REGISTER,ola::NewSingleCallback(&RegisterComplete))) {
|
||||
qDebug() << "Can not register universe %1".arg(m_universe);
|
||||
}*/
|
||||
qDebug() << tr("olaThread| Running");
|
||||
emit toTerminal("Reading DMX");
|
||||
m_clientWrapper->GetSelectServer()->Run();
|
||||
qDebug()<< tr("olaThread|") << "Running";
|
||||
}
|
||||
|
||||
void olaThread::stop()
|
||||
|
@ -111,19 +112,18 @@ bool olaThread::CheckDataLoss() {
|
|||
if (diff.tv_sec > 4 || (diff.tv_sec == 4 && diff.tv_usec > 4000000)) {
|
||||
// loss of data
|
||||
qDebug()<< "olaThread| Can not read one or several universes";
|
||||
// return false; // Retorna false para deshabilitar el callback
|
||||
emit toTerminal("Can not read one universe");
|
||||
// return false; // Retorna false para deshabilitar el callback
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void olaThread::setLayersNumber(int layersNumber) { m_layersNumber = layersNumber; }
|
||||
|
||||
|
||||
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 j = 0; j < LAYER_CHANNELS; j++){
|
||||
emit dmxOutput(i, j, m_dmx[i][j]); // Connected with dmx slot in olaInterface.
|
||||
|
|
|
@ -34,8 +34,6 @@ public:
|
|||
olaThread(QObject *parent = 0);
|
||||
virtual ~olaThread();
|
||||
|
||||
|
||||
|
||||
/** Retorna el valor de un canal
|
||||
*@param int layer the layer for we want the channel
|
||||
*@param int channel the channel for the value wanted
|
||||
|
@ -54,7 +52,6 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
|
||||
void run ();
|
||||
|
||||
ola::client::OlaClientWrapper *m_clientWrapper;
|
||||
|
@ -87,8 +84,10 @@ private:
|
|||
inline void RegisterComplete(const ola::client::Result &error) {
|
||||
if (error.Success()) {
|
||||
qDebug() << "Register Universe success";
|
||||
emit toTerminal("Register Universe success");
|
||||
} else {
|
||||
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 dmxOutput(int layer, int channel, int value); // Signal when a channel has changed
|
||||
void toTerminal(QString message);
|
||||
};
|
||||
|
||||
#endif // OLATHREAD_H
|
||||
|
|
Loading…
Add table
Reference in a new issue