Debug messages to GUI terminal
This commit is contained in:
parent
cccd987bdd
commit
a6909f8c16
7 changed files with 131 additions and 80 deletions
|
@ -7,13 +7,14 @@
|
||||||
|
|
||||||
AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
QGroupBox(parent)
|
QGroupBox(parent)
|
||||||
, m_pullTimer(new QTimer(this))
|
|
||||||
, m_suspendResumeButton(0)
|
, m_suspendResumeButton(0)
|
||||||
, m_deviceBox(0)
|
, m_deviceBox(0)
|
||||||
, m_output(0)
|
, m_pullTimer(new QTimer(this))
|
||||||
, m_device(QAudioDeviceInfo::defaultOutputDevice())
|
, m_device(QAudioDeviceInfo::defaultOutputDevice())
|
||||||
, m_audioOutput(0)
|
, m_audioOutput(0)
|
||||||
|
, m_output(0)
|
||||||
, m_buffer(BufferSize, 0)
|
, m_buffer(BufferSize, 0)
|
||||||
|
, m_decoder(0)
|
||||||
{
|
{
|
||||||
this->setTitle(name);
|
this->setTitle(name);
|
||||||
|
|
||||||
|
@ -110,6 +111,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
m_format = info.nearestFormat(m_format);
|
m_format = info.nearestFormat(m_format);
|
||||||
}
|
}
|
||||||
m_decoder = new AudioDecoder(m_format, this);
|
m_decoder = new AudioDecoder(m_format, this);
|
||||||
|
m_decoder->start();
|
||||||
connect(m_decoder, SIGNAL(totalTimeChanged(qint64)),
|
connect(m_decoder, SIGNAL(totalTimeChanged(qint64)),
|
||||||
this, SLOT(durationChanged(qint64)));
|
this, SLOT(durationChanged(qint64)));
|
||||||
connect(m_pullTimer, SIGNAL(timeout()),
|
connect(m_pullTimer, SIGNAL(timeout()),
|
||||||
|
@ -128,7 +130,8 @@ void AudioLayerWidget::createAudioOutput()
|
||||||
m_audioOutput->setNotifyInterval(100);
|
m_audioOutput->setNotifyInterval(100);
|
||||||
connect(m_audioOutput, SIGNAL(notify()), SLOT(notified()));
|
connect(m_audioOutput, SIGNAL(notify()), SLOT(notified()));
|
||||||
connect(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), SLOT(handleStateChanged(QAudio::State)));
|
connect(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), SLOT(handleStateChanged(QAudio::State)));
|
||||||
m_decoder->start();
|
m_output = m_audioOutput->start();
|
||||||
|
toggleSuspendResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioLayerWidget::deviceChanged(int index)
|
void AudioLayerWidget::deviceChanged(int index)
|
||||||
|
@ -185,8 +188,8 @@ void AudioLayerWidget::pullTimerExpired()
|
||||||
while (chunks) {
|
while (chunks) {
|
||||||
const qint64 len = m_decoder->read(m_buffer.data(), m_audioOutput->periodSize());
|
const qint64 len = m_decoder->read(m_buffer.data(), m_audioOutput->periodSize());
|
||||||
if ( len == -1) {
|
if ( len == -1) {
|
||||||
qDebug() << "End of file";
|
|
||||||
stop();
|
stop();
|
||||||
|
qDebug()<< this->title() << " End of file";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (len) {
|
if (len) {
|
||||||
|
@ -250,9 +253,9 @@ void AudioLayerWidget::fileLoaded(QString file)
|
||||||
|
|
||||||
void AudioLayerWidget::play()
|
void AudioLayerWidget::play()
|
||||||
{
|
{
|
||||||
m_decoder->setPos(0);
|
// m_decoder->setPos(0);
|
||||||
m_output = m_audioOutput->start();
|
|
||||||
m_pullTimer->start(20);
|
m_pullTimer->start(20);
|
||||||
|
m_audioOutput->resume();
|
||||||
m_statusValue->setText(PLAY_LABEL);
|
m_statusValue->setText(PLAY_LABEL);
|
||||||
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
||||||
}
|
}
|
||||||
|
@ -264,10 +267,10 @@ void AudioLayerWidget::pause()
|
||||||
|
|
||||||
void AudioLayerWidget::stop()
|
void AudioLayerWidget::stop()
|
||||||
{
|
{
|
||||||
m_pullTimer->stop();
|
|
||||||
m_audioOutput->suspend();
|
m_audioOutput->suspend();
|
||||||
m_audioOutput->reset();
|
m_pullTimer->stop();
|
||||||
m_decoder->setPos(0);
|
// m_audioOutput->reset();
|
||||||
|
m_decoder->setPos(44);
|
||||||
m_statusValue->setText(STOP_LABEL);
|
m_statusValue->setText(STOP_LABEL);
|
||||||
m_suspendResumeButton->setText(tr(RESUME_LABEL));
|
m_suspendResumeButton->setText(tr(RESUME_LABEL));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define DEFINES_H
|
#define DEFINES_H
|
||||||
|
|
||||||
|
|
||||||
#define VERSION "LibreMediaServer-Audio 0.1.0"
|
#define VERSION "Libre Media Server Audio 0.1.0"
|
||||||
#define COPYRIGHT "(C) 2014 Santi Norena libremediaserver@gmail.com"
|
#define COPYRIGHT "(C) 2014 Santi Norena libremediaserver@gmail.com"
|
||||||
#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"
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ const int BufferSize = 32768;
|
||||||
#define PROGRESS_LABEL "Progress: "
|
#define PROGRESS_LABEL "Progress: "
|
||||||
#define PROGRESS_TIME_LABEL "Current Time: "
|
#define PROGRESS_TIME_LABEL "Current Time: "
|
||||||
#define REMAINING_TIME "Remaining Time: "
|
#define REMAINING_TIME "Remaining Time: "
|
||||||
#define TOTAL_TIME_LABEL "Track Time: "
|
#define TOTAL_TIME_LABEL "Total Time: "
|
||||||
#define FILE_LABEL "File: "
|
#define FILE_LABEL "File: "
|
||||||
#define FOLDER_LABEL "Folder: "
|
#define FOLDER_LABEL "Folder: "
|
||||||
#define STATUS_LABEL "Status: "
|
#define STATUS_LABEL "Status: "
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
*/
|
*/
|
||||||
#include "libremediaserver-audio.h"
|
#include "libremediaserver-audio.h"
|
||||||
|
|
||||||
|
QTextEdit * libreMediaServerAudio::textEdit = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
/ Constructor
|
/ Constructor
|
||||||
*/
|
*/
|
||||||
|
@ -25,25 +30,24 @@
|
||||||
libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
{
|
{
|
||||||
qDebug() << "********************************************************************************";
|
Q_UNUSED(args);
|
||||||
qDebug() << QDate::currentDate().toString() << " "<< QTime::currentTime().toString();
|
|
||||||
qDebug() << VERSION;
|
|
||||||
qDebug() << COPYRIGHT;
|
|
||||||
qDebug() << LICENSE;
|
|
||||||
|
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
this->setWindowTitle(VERSION);
|
|
||||||
// Inicia el widget Terminal
|
// Inicia el widget Terminal
|
||||||
textEdit = new QTextEdit(this);
|
textEdit = new QTextEdit;
|
||||||
textEdit->append(QString::fromLatin1(VERSION));
|
textEdit->setReadOnly(true);
|
||||||
textEdit->append(QString::fromLatin1(LICENSE));
|
|
||||||
textEdit->append(QString::fromLatin1(COPYRIGHT));
|
|
||||||
QDockWidget *bottomWidget = new QDockWidget(tr("Terminal"), this);
|
QDockWidget *bottomWidget = new QDockWidget(tr("Terminal"), this);
|
||||||
bottomWidget->setAllowedAreas(Qt::BottomDockWidgetArea);
|
bottomWidget->setAllowedAreas(Qt::BottomDockWidgetArea);
|
||||||
bottomWidget->setWidget(textEdit);
|
bottomWidget->setWidget(textEdit);
|
||||||
addDockWidget(Qt::BottomDockWidgetArea, bottomWidget);
|
addDockWidget(Qt::BottomDockWidgetArea, bottomWidget);
|
||||||
|
|
||||||
|
this->setWindowTitle(VERSION);
|
||||||
|
|
||||||
|
// qDebug() << QDate::currentDate().toString() << " "<< QTime::currentTime().toString();
|
||||||
|
qDebug() << VERSION;
|
||||||
|
qDebug() << COPYRIGHT;
|
||||||
|
qDebug() << LICENSE;
|
||||||
|
|
||||||
// Inicia el widget central de audio
|
// Inicia el widget central de audio
|
||||||
aw = new AudioWidget(this);
|
aw = new AudioWidget(this);
|
||||||
setCentralWidget(aw);
|
setCentralWidget(aw);
|
||||||
|
@ -51,11 +55,19 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
||||||
// Inicia la lectura de dmx a través de ola
|
// Inicia la lectura de dmx a través de ola
|
||||||
ola = new olaThread();
|
ola = new olaThread();
|
||||||
Q_CHECK_PTR(ola);
|
Q_CHECK_PTR(ola);
|
||||||
connect(ola, SIGNAL(toTerminal(QString)),
|
|
||||||
this, SLOT(toTerminal(QString)));
|
|
||||||
ola->start(QThread::TimeCriticalPriority );
|
|
||||||
ola->blockSignals(true);
|
|
||||||
|
|
||||||
|
connect(ola, SIGNAL(toTerminal(QString)),
|
||||||
|
textEdit, SLOT(append(QString)), Qt::QueuedConnection);
|
||||||
|
|
||||||
|
ola->blockSignals(true);
|
||||||
|
ola->start(QThread::TimeCriticalPriority );
|
||||||
|
|
||||||
|
/* connect(MediaLibrary::getInstance(), SIGNAL(debug(QString)),
|
||||||
|
textEdit, SLOT(append(QString)), Qt::QueuedConnection);
|
||||||
|
|
||||||
|
connect(MediaLibrary::getInstance(), SIGNAL(warning(QString)),
|
||||||
|
textEdit, SLOT(append(QString)), Qt::QueuedConnection);
|
||||||
|
*/
|
||||||
// Inicia el widget Master. No implementado todavía
|
// Inicia el widget Master. No implementado todavía
|
||||||
/*
|
/*
|
||||||
amw = new AudioMasterWidget(this);
|
amw = new AudioMasterWidget(this);
|
||||||
|
@ -64,11 +76,6 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
||||||
topWidget->setWidget(amw);
|
topWidget->setWidget(amw);
|
||||||
addDockWidget(Qt::TopDockWidgetArea, topWidget);
|
addDockWidget(Qt::TopDockWidgetArea, topWidget);
|
||||||
*/
|
*/
|
||||||
if (args.contains("-log"))
|
|
||||||
{
|
|
||||||
textEdit->append("Log to file");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Conectamos los menus
|
// Conectamos los menus
|
||||||
connect(ui.actionOpen_conf, SIGNAL(triggered()), this, SLOT(openFile()));
|
connect(ui.actionOpen_conf, SIGNAL(triggered()), this, SLOT(openFile()));
|
||||||
connect(ui.actionSave_conf, SIGNAL(triggered()), this, SLOT(saveFile()));
|
connect(ui.actionSave_conf, SIGNAL(triggered()), this, SLOT(saveFile()));
|
||||||
|
@ -98,11 +105,11 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
||||||
libreMediaServerAudio::~libreMediaServerAudio()
|
libreMediaServerAudio::~libreMediaServerAudio()
|
||||||
{
|
{
|
||||||
// save_finish();
|
// save_finish();
|
||||||
delete MediaLibrary::getInstance();
|
// delete MediaLibrary::getInstance();
|
||||||
ola->stop();
|
// ola->stop();
|
||||||
qDebug() << QDate::currentDate().toString() << " " << QTime::currentTime().toString();
|
// qDebug() << QDate::currentDate().toString() << " " << QTime::currentTime().toString();
|
||||||
qDebug() << "********************************************************************************";
|
// qDebug() << "********************************************************************************";
|
||||||
return;
|
// return;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -51,13 +51,15 @@ public:
|
||||||
|
|
||||||
Ui::LibreMediaServerAudio ui;
|
Ui::LibreMediaServerAudio ui;
|
||||||
|
|
||||||
|
static QTextEdit *textEdit; // Terminal de feedback
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
QString m_pathmedia; // Path to Medias
|
QString m_pathmedia; // Path to Medias
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QTextEdit *textEdit; // Terminal de feedback
|
// void MessageHandler(QtMsgType type, const QMessageLogContext &logcontext, const QString &msg);
|
||||||
AudioMasterWidget *amw;
|
AudioMasterWidget *amw;
|
||||||
AudioWidget *aw;
|
AudioWidget *aw;
|
||||||
olaThread *ola;
|
olaThread *ola;
|
||||||
|
@ -68,11 +70,7 @@ private:
|
||||||
void save(QFile *file);
|
void save(QFile *file);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
// inline void toTerminal(QString msg) { textEdit->append(msg); }
|
||||||
inline void toTerminal (QString message)
|
|
||||||
{
|
|
||||||
textEdit->append(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,8 @@ FORMS += \
|
||||||
|
|
||||||
#INCLUDEPATH += ./
|
#INCLUDEPATH += ./
|
||||||
|
|
||||||
LIBS += -L./debug -lola -lolacommon
|
LIBS += -lola -lolacommon
|
||||||
|
# -L./debug
|
||||||
|
|
||||||
#win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../debug/release/ -lcitp
|
#win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../debug/release/ -lcitp
|
||||||
#else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../debug/debug/ -lcitp
|
#else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../debug/debug/ -lcitp
|
||||||
|
@ -43,7 +44,6 @@ LIBS += -L./debug -lola -lolacommon
|
||||||
|
|
||||||
RESOURCES =
|
RESOURCES =
|
||||||
|
|
||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
../LICENSE.txt \
|
../LICENSE.txt \
|
||||||
../instalacion.txt \
|
../instalacion.txt \
|
||||||
|
|
101
src/main.cpp
101
src/main.cpp
|
@ -19,36 +19,22 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QMutexLocker>
|
||||||
#include "libremediaserver-audio.h"
|
#include "libremediaserver-audio.h"
|
||||||
|
|
||||||
// Handler for pipe the stderr to a log file
|
// Handler for pipe the stderr to a log file and texEdit
|
||||||
bool initMessageHandler = false;
|
bool initMessageHandler = false;
|
||||||
QFile outFile;
|
QFile outFile;
|
||||||
|
QMutex mutex;
|
||||||
|
//QMutexLocker mutexLocker(mutex);
|
||||||
|
|
||||||
void MessageHandler(QtMsgType type, const QMessageLogContext &logcontext, const QString &msg)
|
void MessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||||
{
|
{
|
||||||
Q_UNUSED(logcontext);
|
Q_UNUSED(context);
|
||||||
QString txt;
|
// mutex.lock();
|
||||||
switch (type) {
|
|
||||||
case QtDebugMsg:
|
|
||||||
txt.append("Debug: ");
|
|
||||||
txt.append(msg);
|
|
||||||
break;
|
|
||||||
case QtWarningMsg:
|
|
||||||
txt.append("Warning: ");
|
|
||||||
txt.append(msg);
|
|
||||||
break;
|
|
||||||
case QtCriticalMsg:
|
|
||||||
txt.append("Critical: ");
|
|
||||||
txt.append(msg);
|
|
||||||
break;
|
|
||||||
case QtFatalMsg:
|
|
||||||
txt.append("Fatal: ");
|
|
||||||
txt.append(msg);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
// Create the log dir and log file
|
// Create the log dir and log file
|
||||||
if (!initMessageHandler) {
|
/* if (!initMessageHandler) {
|
||||||
QDir dir;
|
QDir dir;
|
||||||
if (!dir.exists("log")) {
|
if (!dir.exists("log")) {
|
||||||
if (!dir.mkdir("log")) {
|
if (!dir.mkdir("log")) {
|
||||||
|
@ -69,13 +55,74 @@ void MessageHandler(QtMsgType type, const QMessageLogContext &logcontext, const
|
||||||
}
|
}
|
||||||
initMessageHandler = true;
|
initMessageHandler = true;
|
||||||
}
|
}
|
||||||
QTextStream ts(&outFile);
|
QTextStream ts(&outFile);*/
|
||||||
ts << txt << endl;
|
if (libreMediaServerAudio::textEdit == 0)
|
||||||
|
{
|
||||||
|
QByteArray localMsg = msg.toLocal8Bit();
|
||||||
|
switch (type) {
|
||||||
|
case QtDebugMsg:
|
||||||
|
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||||
|
break;
|
||||||
|
case QtWarningMsg:
|
||||||
|
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||||
|
break;
|
||||||
|
case QtCriticalMsg:
|
||||||
|
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||||
|
break;
|
||||||
|
case QtFatalMsg:
|
||||||
|
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QString txt;
|
||||||
|
switch (type) {
|
||||||
|
case QtDebugMsg:
|
||||||
|
txt.append("Debug: ");
|
||||||
|
txt.append(context.file);
|
||||||
|
txt.append(context.line);
|
||||||
|
txt.append(context.function);
|
||||||
|
txt.append(msg);
|
||||||
|
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
|
||||||
|
libreMediaServerAudio::textEdit->append(txt);
|
||||||
|
break;
|
||||||
|
case QtWarningMsg:
|
||||||
|
// txt.append("Warning: ");
|
||||||
|
// txt.append(msg);
|
||||||
|
libreMediaServerAudio::textEdit->append(msg);
|
||||||
|
break;
|
||||||
|
case QtCriticalMsg:
|
||||||
|
// txt.append("Critical: ");
|
||||||
|
// txt.append(msg);
|
||||||
|
libreMediaServerAudio::textEdit->append(msg);
|
||||||
|
break;
|
||||||
|
case QtFatalMsg:
|
||||||
|
// txt.append("Fatal: ");
|
||||||
|
// txt.append(msg);
|
||||||
|
libreMediaServerAudio::textEdit->append(msg);
|
||||||
|
// ts << txt << endl;
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
// outFile.write(txt.toLatin1().constData(), txt.size());
|
||||||
|
// ts << txt << endl;
|
||||||
|
// libreMediaServerAudio::textEdit->append(txt);
|
||||||
|
}
|
||||||
|
// mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// ToDo: discriminar niveles de log y log a fichero segúna argumentos
|
||||||
|
/*
|
||||||
|
if (args.contains("-log"))
|
||||||
|
{
|
||||||
|
qInstallMessageHandler(MessageHandler);
|
||||||
|
}*/
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
qInstallMessageHandler(MessageHandler);
|
||||||
QStringList args = app.arguments();
|
QStringList args = app.arguments();
|
||||||
// parse the command line
|
// parse the command line
|
||||||
if (args.size() > 1)
|
if (args.size() > 1)
|
||||||
|
@ -98,10 +145,6 @@ int main(int argc, char *argv[])
|
||||||
qDebug() << "-h this help";
|
qDebug() << "-h this help";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (args.contains("-log"))
|
|
||||||
{
|
|
||||||
qInstallMessageHandler(MessageHandler);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
libreMediaServerAudio libreMediaServerAudio(args);
|
libreMediaServerAudio libreMediaServerAudio(args);
|
||||||
libreMediaServerAudio.show();
|
libreMediaServerAudio.show();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
olaThread::olaThread(QObject *parent)
|
olaThread::olaThread(QObject *parent)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(parent);
|
||||||
m_universe = new QList<int>();
|
m_universe = new QList<int>();
|
||||||
m_counter = 0;
|
m_counter = 0;
|
||||||
gettimeofday(&m_last_data, NULL);
|
gettimeofday(&m_last_data, NULL);
|
||||||
|
@ -27,7 +28,7 @@ olaThread::olaThread(QObject *parent)
|
||||||
ola::InitLogging(ola::OLA_LOG_INFO , ola::OLA_LOG_STDERR);
|
ola::InitLogging(ola::OLA_LOG_INFO , ola::OLA_LOG_STDERR);
|
||||||
m_client->SetDMXCallback(ola::NewCallback(this, &olaThread::NewDmx));
|
m_client->SetDMXCallback(ola::NewCallback(this, &olaThread::NewDmx));
|
||||||
m_clientWrapper->GetSelectServer()->RegisterRepeatingTimeout(4000, ola::NewCallback(this, &olaThread::CheckDataLoss));
|
m_clientWrapper->GetSelectServer()->RegisterRepeatingTimeout(4000, ola::NewCallback(this, &olaThread::CheckDataLoss));
|
||||||
qDebug() << "Init olaThread";
|
// qDebug() << "Init olaThread";
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- DECONSTRUCTOR ---
|
// --- DECONSTRUCTOR ---
|
||||||
|
@ -40,7 +41,7 @@ olaThread::~olaThread() {
|
||||||
|
|
||||||
void olaThread::run()
|
void olaThread::run()
|
||||||
{
|
{
|
||||||
qDebug() << tr("olaThread| Running");
|
// qDebug() << tr("olaThread| Running");
|
||||||
emit toTerminal("Reading DMX");
|
emit toTerminal("Reading DMX");
|
||||||
m_clientWrapper->GetSelectServer()->Run();
|
m_clientWrapper->GetSelectServer()->Run();
|
||||||
}
|
}
|
||||||
|
@ -72,7 +73,7 @@ void olaThread::NewDmx(const ola::client::DMXMetadata &data,
|
||||||
{
|
{
|
||||||
m_counter++;
|
m_counter++;
|
||||||
gettimeofday(&m_last_data, NULL);
|
gettimeofday(&m_last_data, NULL);
|
||||||
int universe = data.universe;
|
uint universe = data.universe;
|
||||||
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.
|
||||||
if((m_settings.at(i).universe == universe)
|
if((m_settings.at(i).universe == universe)
|
||||||
&& ( m_settings.at(i).address > -1 )) { // Compare if the layer is from this universe
|
&& ( m_settings.at(i).address > -1 )) { // Compare if the layer is from this universe
|
||||||
|
@ -99,8 +100,8 @@ bool olaThread::CheckDataLoss() {
|
||||||
timersub(&now, &m_last_data, &diff);
|
timersub(&now, &m_last_data, &diff);
|
||||||
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");
|
emit toTerminal("olaThread: Can not read one universe");
|
||||||
// return false; // Retorna false para deshabilitar el callback
|
// return false; // Retorna false para deshabilitar el callback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,14 +112,13 @@ void olaThread::setLayersNumber(int layersNumber) { m_layersNumber = layersNumbe
|
||||||
|
|
||||||
void olaThread::resendDmx()
|
void olaThread::resendDmx()
|
||||||
{
|
{
|
||||||
emit toTerminal("Resending DMX info");
|
// qDebug() << "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.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue