Initial commit
This commit is contained in:
commit
45115830c0
30 changed files with 2923 additions and 0 deletions
126
src/olathread.h
Normal file
126
src/olathread.h
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
#ifndef OLATHREAD_H
|
||||
#define OLATHREAD_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <ola/DmxBuffer.h>
|
||||
#include <ola/Logging.h>
|
||||
#include <ola/OlaClientWrapper.h>
|
||||
#include <ola/client/OlaClient.h>
|
||||
#include <ola/DmxBuffer.h>
|
||||
#include <ola/client/ClientTypes.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "dmxPersonality.h"
|
||||
|
||||
// struct where save the DMX settings for each layer
|
||||
struct dmxSetting {
|
||||
int address;
|
||||
uint universe;
|
||||
bool updated;
|
||||
int layer;
|
||||
};
|
||||
|
||||
class olaThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
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
|
||||
*@return int the value
|
||||
*/
|
||||
|
||||
inline int getValue(int layer, int channel) {
|
||||
return m_dmx[layer][channel];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief resendDMX emite todo el buffer DMX
|
||||
*/
|
||||
|
||||
void resendDmx();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
void run ();
|
||||
|
||||
ola::client::OlaClientWrapper *m_clientWrapper;
|
||||
ola::client::OlaClient *m_client;
|
||||
unsigned int m_counter;
|
||||
struct timeval m_last_data; // Last DMX frame received
|
||||
|
||||
// DMX Conf
|
||||
// Cambiar para múltiples universos. Array? método de de ola::client?
|
||||
QList<int> *m_universe; // Registered universes.
|
||||
int m_layersNumber; // Number of layers in wich divide the dmx frame. Each layer, one source.
|
||||
|
||||
int m_dmx[LAYERS_NUMBER][LAYER_CHANNELS]; // DMX Buffer. Habría que cambiarlo si queremos hacer las capas dinámicas
|
||||
|
||||
QList<dmxSetting> m_settings;
|
||||
|
||||
inline void registerUniverse(int universe)
|
||||
{
|
||||
|
||||
// void ola::client::OlaClient::RegisterUniverse(unsigned int universe,RegisterAction register_action,SetCallback * callback
|
||||
m_client->RegisterUniverse(universe, ola::client::REGISTER,ola::NewSingleCallback(this, &olaThread::RegisterComplete));
|
||||
}
|
||||
|
||||
/**
|
||||
* Control de errores en el registro de Universos en OLA
|
||||
*/
|
||||
|
||||
// typedef SingleUseCallback1<void, const Result&> ola::client::SetCallback
|
||||
|
||||
inline void RegisterComplete(const ola::client::Result &error) {
|
||||
if (error.Success()) {
|
||||
qDebug() << "Register Universe success";
|
||||
} else {
|
||||
qWarning() << "olaThread|" << "Register command failed" << QString::fromStdString(error.Error());
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckDataLoss();
|
||||
|
||||
// typedef Callback2<void, const DMXMetadata&, const DmxBuffer&> ola::client::RepeatableDMXCallback
|
||||
void NewDmx(const ola::client::DMXMetadata &dmx_meta, const ola::DmxBuffer &buffer); // Callback from OlaCLient when there is new dmx info
|
||||
|
||||
public slots:
|
||||
|
||||
void stop(); // Close the connection with olad.
|
||||
void setLayersNumber(int layersNumber);
|
||||
|
||||
inline void setDMXConf(dmxSetting set)
|
||||
{
|
||||
if (set.layer >= m_layersNumber) { return; }
|
||||
|
||||
m_settings.replace(set.layer, set);
|
||||
|
||||
// ToDo: registro del nuevo universo si no está registrado ya
|
||||
if (!m_universe->contains(set.universe)) {
|
||||
registerUniverse(set.universe);
|
||||
m_universe->append(set.universe);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
#endif // OLATHREAD_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue