implement origin for effects (#408)

* implement rigin for efx

* implement origin for effects and other components
add experimental adalight firmware for arduino with upto 5 pwm channels

* cleanup

* origin ip now with dns lookup

* fix compile

* move some code
This commit is contained in:
redPanther
2017-03-01 15:23:53 +01:00
committed by GitHub
parent 31f352e7ce
commit 221af075a4
24 changed files with 376 additions and 98 deletions

View File

@@ -87,5 +87,5 @@ private:
/// state of connection
bool _isActive;
uint16_t _port;
uint16_t _port;
};

View File

@@ -45,13 +45,10 @@ public:
public slots:
/// Run the specified effect on the given priority channel and optionally specify a timeout
int runEffect(const QString &effectName, int priority, int timeout = -1)
{
return runEffect(effectName, QJsonObject(), priority, timeout);
};
int runEffect(const QString &effectName, int priority, int timeout = -1, const QString &origin="System");
/// Run the specified effect on the given priority channel and optionally specify a timeout
int runEffect(const QString &effectName, const QJsonObject & args, int priority, int timeout = -1, QString pythonScript = "");
int runEffect(const QString &effectName, const QJsonObject & args, int priority, int timeout = -1, const QString &pythonScript = "", const QString &origin = "System");
/// Clear any effect running on the provided channel
void channelCleared(int priority);
@@ -68,7 +65,7 @@ private:
bool loadEffectSchema(const QString & path, const QString & effectSchemaFile, EffectSchema &effectSchema);
/// Run the specified effect on the given priority channel and optionally specify a timeout
int runEffectScript(const QString &script, const QString &name, const QJsonObject & args, int priority, int timeout = -1);
int runEffectScript(const QString &script, const QString &name, const QJsonObject & args, int priority, int timeout = -1, const QString & origin="System");
private:
Hyperion * _hyperion;

View File

@@ -52,7 +52,7 @@ class Hyperion : public QObject
public:
/// Type definition of the info structure used by the priority muxer
typedef PriorityMuxer::InputInfo InputInfo;
typedef std::map<std::string,int> PriorityRegister;
typedef std::map<QString,int> PriorityRegister;
///
/// RGB-Color channel enumeration
@@ -132,12 +132,13 @@ public:
/// register a input source to a priority channel
/// @param name uniq name of input source
/// @param origin External setter
/// @param priority priority channel
void registerPriority(const std::string name, const int priority);
void registerPriority(const QString &name, const int priority);
/// unregister a input source to a priority channel
/// @param name uniq name of input source
void unRegisterPriority(const std::string name);
void unRegisterPriority(const QString &name);
/// gets current priority register
/// @return the priority register
@@ -243,14 +244,15 @@ public slots:
/// @param effectName Name of the effec to run
/// @param priority The priority channel of the effect
/// @param timeout The timeout of the effect (after the timout, the effect will be cleared)
int setEffect(const QString & effectName, int priority, int timeout = -1);
int setEffect(const QString & effectName, int priority, int timeout = -1, const QString & origin="System");
/// Run the specified effect on the given priority channel and optionally specify a timeout
/// @param effectName Name of the effec to run
/// @param args arguments of the effect script
/// @param priority The priority channel of the effect
/// @param timeout The timeout of the effect (after the timout, the effect will be cleared)
int setEffect(const QString & effectName, const QJsonObject & args, int priority, int timeout = -1, QString pythonScript = "");
int setEffect(const QString & effectName, const QJsonObject & args, int priority,
int timeout = -1, const QString & pythonScript = "", const QString & origin="System");
/// sets the methode how image is maped to leds
void setLedMappingType(int mappingType);

View File

@@ -63,7 +63,7 @@ private slots:
/// Slot which is called when a client tries to create a new connection
///
void readPendingDatagrams();
void processTheDatagram(const QByteArray * _datagram);
void processTheDatagram(const QByteArray * datagram, const QHostAddress * sender);
private:
/// Hyperion instance
@@ -78,7 +78,7 @@ private:
/// hyperion priority
int _priority;
/// hyperion priority
/// hyperion timeout
int _timeout;
/// Logger instance
@@ -88,7 +88,7 @@ private:
bool _isActive;
/// address to bind
QHostAddress _listenAddress;
quint16 _listenPort;
QHostAddress _listenAddress;
quint16 _listenPort;
QAbstractSocket::BindFlag _bondage;
};

View File

@@ -18,7 +18,8 @@ enum Components
COMP_GRABBER,
COMP_V4L,
COMP_COLOR,
COMP_EFFECT
COMP_EFFECT,
COMP_PROTOSERVER
};
inline const char* componentToString(Components c)
@@ -35,6 +36,7 @@ inline const char* componentToString(Components c)
case COMP_V4L: return "V4L capture device";
case COMP_COLOR: return "Solid color";
case COMP_EFFECT: return "Effect";
case COMP_PROTOSERVER: return "Proto Server";
default: return "";
}
}
@@ -53,6 +55,7 @@ inline const char* componentToIdString(Components c)
case COMP_V4L: return "V4L";
case COMP_COLOR: return "COLOR";
case COMP_EFFECT: return "EFFECT";
case COMP_PROTOSERVER: return "PROTOSERVER";
default: return "";
}
}
@@ -70,8 +73,9 @@ inline Components stringToComponent(QString component)
if (component == "V4L") return COMP_V4L;
if (component == "COLOR") return COMP_COLOR;
if (component == "EFFECT") return COMP_EFFECT;
if (component == "PROTOSERVER") return COMP_PROTOSERVER;
return COMP_INVALID;
}
}
}; // end of namespace

View File

@@ -11,7 +11,7 @@
#include <map>
#include <QVector>
#include <utils/global_defines.h>
// standard log messages
//#define _FUNCNAME_ __PRETTY_FUNCTION__
@@ -99,3 +99,5 @@ protected:
QVector<Logger::T_LOG_MESSAGE> _logMessageBuffer;
const int _loggerMaxMsgBufferSize;
};
Q_DECLARE_METATYPE(Logger::T_LOG_MESSAGE);

View File

@@ -0,0 +1,4 @@
#pragma once
#define QSTRING_CSTR(str) str.toLocal8Bit().constData()