2013-11-24 16:10:48 +01:00
|
|
|
#pragma once
|
|
|
|
|
2013-11-26 21:38:24 +01:00
|
|
|
// Qt includes
|
|
|
|
#include <QThread>
|
2013-11-24 16:10:48 +01:00
|
|
|
|
2013-11-26 21:38:24 +01:00
|
|
|
// Python includes
|
|
|
|
#include <Python.h>
|
|
|
|
|
2013-11-28 14:38:07 +01:00
|
|
|
// Hyperion includes
|
|
|
|
#include <hyperion/ImageProcessor.h>
|
|
|
|
|
2013-11-26 21:38:24 +01:00
|
|
|
class Effect : public QThread
|
2013-11-24 16:10:48 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2013-11-26 21:38:24 +01:00
|
|
|
Effect(int priority, int timeout);
|
2013-11-24 16:10:48 +01:00
|
|
|
virtual ~Effect();
|
2013-11-26 21:38:24 +01:00
|
|
|
|
|
|
|
virtual void run();
|
|
|
|
|
|
|
|
int getPriority() const;
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void abort();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void effectFinished(Effect * effect);
|
|
|
|
|
2013-11-29 23:22:49 +01:00
|
|
|
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms);
|
|
|
|
|
2013-11-26 21:38:24 +01:00
|
|
|
private slots:
|
|
|
|
void effectFinished();
|
|
|
|
|
2013-11-28 14:15:52 +01:00
|
|
|
private:
|
|
|
|
// Wrapper methods for Python interpreter extra buildin methods
|
|
|
|
static PyMethodDef effectMethods[];
|
|
|
|
static PyObject* wrapSetColor(PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapSetImage(PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapAbort(PyObject *self, PyObject *args);
|
2013-11-28 14:29:31 +01:00
|
|
|
static Effect * getEffect(PyObject *self);
|
2013-11-28 14:15:52 +01:00
|
|
|
|
2013-11-26 21:38:24 +01:00
|
|
|
private:
|
|
|
|
const int _priority;
|
|
|
|
|
|
|
|
const int _timeout;
|
2013-11-29 23:22:49 +01:00
|
|
|
|
2013-11-28 14:29:31 +01:00
|
|
|
int64_t _endTime;
|
2013-11-26 21:38:24 +01:00
|
|
|
|
|
|
|
PyThreadState * _interpreterThreadState;
|
|
|
|
|
|
|
|
bool _abortRequested;
|
2013-11-28 14:38:07 +01:00
|
|
|
|
|
|
|
/// The processor for translating images to led-values
|
|
|
|
ImageProcessor * _imageProcessor;
|
2013-11-24 16:10:48 +01:00
|
|
|
};
|