funcionando controles ui

This commit is contained in:
snt 2024-04-23 01:16:52 +02:00
parent abf5d3340f
commit b59cc92c5f
10 changed files with 50 additions and 125 deletions

View file

@ -5,7 +5,6 @@
#include <QObject>
#include <QThread>
#include <QDebug>
#include <ola/DmxBuffer.h>
#include <ola/Logging.h>
@ -25,7 +24,7 @@ class olaThread : public QThread
public:
olaThread(QObject *parent = 0);
olaThread(QObject *parent = 0, int layers = 0);
virtual ~olaThread();
/** Retorna el valor de un canal
@ -37,9 +36,6 @@ public:
return m_dmx[layer][channel];
}
/**
* @brief resendDMX emite todo el buffer DMX
*/
void resendDmx();
private:
@ -49,78 +45,49 @@ private:
ola::client::OlaClient *m_client;
unsigned int m_counter;
struct timeval m_last_data; // Last DMX frame received
int m_dmx[MAX_LAYERS][LAYER_CHANNELS]; // DMX Buffer. Habría que cambiarlo si queremos hacer las capas dinámicas
int m_layers;
int m_dmx[MAX_LAYERS][LAYER_CHANNELS];
/**
* @brief Callback from ola. Control de errores en el registro de Universos en OLA
* typedef SingleUseCallback1<void, const Result&> ola::client::SetCallback
* @param ola::client::Result &error
* @return void
*
*
*/
inline void RegisterComplete(const ola::client::Result &error) {
if (error.Success()) {
qDebug("Register Universe success");
emit toTerminal("Register Universe success");
} else {
qWarning("Register command failed: %s", error.Error().c_str());
emit toTerminal("olaThread| Register command failed " + QString::fromStdString(error.Error()));
}
}
/**
* @brief Check if the dmx info is arriving each 4 seconds
* @return bool
*/
bool CheckDataLoss();
/**
* @brief RepeteableDMXCallBack from ola called when arrives a new dmx frame
* typedef Callback2<void, const DMXMetadata&, const DmxBuffer&> ola::client::RepeatableDMXCallback
* This is called one for second if there is not updated in the DMX frame. We need emit only the channels that
* has changed to save resources.
*
*
* This is called one for second if there is not updated in the DMX frame.
* emit only the channels that has been changed.
*/
void NewDmx(const ola::client::DMXMetadata &dmx_meta, const ola::DmxBuffer &buffer); //
/**
* @brief Sometimes the ola server closes the connection. This is a callback to handle this event an reconect to ola
*
*
*/
void socketClosed();
/**
* @brief Open the connection with olad and start processing data.
*
*
*/
void init();
void init();
public slots:
void stop(); // Close the connection with olad.
/**
* @brief register one Universe
* void ola::client::OlaClient::RegisterUniverse(unsigned int universe,RegisterAction register_action,SetCallback * callback
* @param universe
*/
void stop();
inline void registerUniverse(int universe) {
qDebug("Registering universe %d", universe);
qInfo("Registering universe %d", universe);
m_client->RegisterUniverse(universe,
ola::client::REGISTER,
ola::NewSingleCallback
(this, &olaThread::RegisterComplete));
}
/**
* @brief Register all the universes again
*
*/
inline void registerUniverse() {
QSet<int> unis = Settings::getInstance()->getUniverses();
foreach (const int &universe, unis) {
@ -128,15 +95,8 @@ public slots:
}
}
protected slots:
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);
void universeReceived(uint universe);
void layerReceived();
void dmxOutput(int layer, int channel, int value);
};
using namespace ola;