remove boblight from project tree (is now a separat repository)

This commit is contained in:
Simon Stürz 2016-02-21 11:26:23 +01:00 committed by Michael Zanetti
parent 317c5e7ea7
commit f04257ab33
9 changed files with 0 additions and 464 deletions

View File

@ -1,132 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2015 Simon Stuerz <simon.stuerz@guh.guru> *
* Copyright (C) 2014 Michael Zanetti <michael_zanetti@gmx.net> *
* *
* This file is part of guh. *
* *
* Guh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, version 2 of the License. *
* *
* Guh is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "bobclient.h"
#include "extern-plugininfo.h"
#include "libboblight/boblight.h"
#include <QDebug>
BobClient::BobClient(QObject *parent) :
QObject(parent),
m_connected(false),
m_port(-1)
{
m_lastSyncTime = QTime::currentTime();
m_resyncTimer.setInterval(200);
m_resyncTimer.setSingleShot(true);
QObject::connect(&m_resyncTimer, SIGNAL(timeout()), SLOT(sync()));
}
bool BobClient::connect(const QString &hostname, int port)
{
qCDebug(dcBoblight) << "Connecting to boblightd\n";
m_boblight = boblight_init();
//try to connect, if we can't then bitch to stderr and destroy boblight
if (!boblight_connect(m_boblight, hostname.toLatin1().data(), port, 5000000) ||
!boblight_setpriority(m_boblight, 1))
{
qCWarning(dcBoblight) << "Failed to connect:" << boblight_geterror(m_boblight);
boblight_destroy(m_boblight);
m_connected = false;
return false;
}
qCDebug(dcBoblight) << "Connection to boblightd opened\n";
m_hostname = hostname;
m_port = port;
m_connected = true;
return true;
}
bool BobClient::connected() const
{
return m_connected;
}
void BobClient::setPriority(int priority)
{
qCDebug(dcBoblight) << "setting new priority:" << priority;
qCDebug(dcBoblight) << "setting priority to" << priority << boblight_setpriority(m_boblight, priority);
}
void BobClient::setColor(int channel, QColor color)
{
if(channel == -1) {
for(int i = 0; i < lightsCount(); ++i) {
setColor(i, color);
}
} else {
m_colors[channel] = color;
qCDebug(dcBoblight) << "set channel" << channel << "to color" << color;
}
}
void BobClient::sync()
{
if(!m_connected) {
qCWarning(dcBoblight) << "Not connected to boblight. Cannot sync";
return;
}
if(m_lastSyncTime.addMSecs(50) > QTime::currentTime()) {
if(!m_resyncTimer.isActive()) {
m_resyncTimer.start();
}
return;
}
qCDebug(dcBoblight) << "syncing";
m_lastSyncTime = QTime::currentTime();
for(int i = 0; i < lightsCount(); ++i) {
//load the color into int array
int rgb[3];
rgb[0] = m_colors[i].red() * m_colors[i].alphaF();
rgb[1] = m_colors[i].green() * m_colors[i].alphaF();
rgb[2] = m_colors[i].blue() * m_colors[i].alphaF();
qCDebug(dcBoblight) << "set color" << rgb[0] << rgb[1] << rgb[2];
//set all lights to the color we want and send it
boblight_addpixel(m_boblight, i, rgb);
}
if (!boblight_sendrgb(m_boblight, 1, NULL)) //some error happened, probably connection broken, so bitch and try again
{
qCWarning(dcBoblight) << "Boblight connection error:" << boblight_geterror(m_boblight);
boblight_destroy(m_boblight);
m_connected = false;
connect(m_hostname, m_port);
}
}
int BobClient::lightsCount()
{
return boblight_getnrlights(m_boblight);
}
QColor BobClient::currentColor(int channel)
{
return m_colors[channel];
}

View File

@ -1,61 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2015 Simon Stuerz <simon.stuerz@guh.guru> *
* Copyright (C) 2014 Michael Zanetti <michael_zanetti@gmx.net> *
* *
* This file is part of guh. *
* *
* Guh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, version 2 of the License. *
* *
* Guh is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef BOBCLIENT_H
#define BOBCLIENT_H
#include <QObject>
#include <QTimer>
#include <QMap>
#include <QColor>
#include <QTime>
class BobClient : public QObject
{
Q_OBJECT
public:
explicit BobClient(QObject *parent = 0);
bool connect(const QString &hostname, int port);
bool connected() const;
int lightsCount();
QColor currentColor(int channel);
void setPriority(int priority);
signals:
public slots:
void setColor(int channel, QColor color);
void sync();
private:
QMap<int, QColor> m_colors; //channel, color
void *m_boblight;
bool m_connected;
QString m_hostname;
int m_port;
QTime m_lastSyncTime;
QTimer m_resyncTimer;
};
#endif // BOBCLIENT_H

View File

@ -1,17 +0,0 @@
include(../../plugins.pri)
TARGET = $$qtLibraryTarget(guh_devicepluginboblight)
INCLUDEPATH += /usr/local/include/
LIBS += -L/usr/local/lib/libboblight.a
SOURCES += \
devicepluginboblight.cpp \
bobclient.cpp \
HEADERS += \
devicepluginboblight.h \
bobclient.h \

View File

@ -1,142 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2015 Simon Stuerz <simon.stuerz@guh.guru> *
* Copyright (C) 2014 Michael Zanetti <michael_zanetti@gmx.net> *
* *
* This file is part of guh. *
* *
* Guh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, version 2 of the License. *
* *
* Guh is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\page boblight.html
\title Boblight
\ingroup plugins
\ingroup network
This plugin allows to communicate with a \l{https://code.google.com/p/boblight/}{boblight} server
running on localhost:19333. If a boblight server is running ,the configured light devices from the server will
appear automatically in guh.
\chapter Plugin properties
Following JSON file contains the definition and the description of all available \l{DeviceClass}{DeviceClasses}
and \l{Vendor}{Vendors} of this \l{DevicePlugin}.
Each \l{DeviceClass} has a list of \l{ParamType}{paramTypes}, \l{ActionType}{actionTypes}, \l{StateType}{stateTypes}
and \l{EventType}{eventTypes}. The \l{DeviceClass::CreateMethod}{createMethods} parameter describes how the \l{Device}
will be created in the system. A device can have more than one \l{DeviceClass::CreateMethod}{CreateMethod}.
The \l{DeviceClass::SetupMethod}{setupMethod} describes the setup method of the \l{Device}.
The detailed implementation of each \l{DeviceClass} can be found in the source code.
\note If a \l{StateType} has the parameter \tt{"writable": {...}}, an \l{ActionType} with the same uuid and \l{ParamType}{ParamTypes}
will be created automatically.
\quotefile plugins/deviceplugins/boblight/devicepluginboblight.json
*/
#include "devicepluginboblight.h"
#include "plugin/device.h"
#include "devicemanager.h"
#include "bobclient.h"
#include "plugininfo.h"
#include <QDebug>
#include <QStringList>
DevicePluginBoblight::DevicePluginBoblight()
{
m_bobClient = new BobClient(this);
connect(this, &DevicePlugin::configValueChanged, this, &DevicePluginBoblight::connectToBoblight);
}
DeviceManager::HardwareResources DevicePluginBoblight::requiredHardware() const
{
return DeviceManager::HardwareResourceNone;
}
void DevicePluginBoblight::startMonitoringAutoDevices()
{
if (!m_bobClient->connected()) {
return;
}
QList<Device*> loadedDevices = deviceManager()->findConfiguredDevices(boblightDeviceClassId);
QList<DeviceDescriptor> deviceDescriptorList;
for (int i = loadedDevices.count(); i < m_bobClient->lightsCount(); i++) {
DeviceDescriptor deviceDescriptor(boblightDeviceClassId, "Boblight Channel " + QString::number(i));
ParamList params;
Param param("channel");
param.setValue(i);
params.append(param);
deviceDescriptor.setParams(params);
deviceDescriptorList.append(deviceDescriptor);
}
emit autoDevicesAppeared(boblightDeviceClassId, deviceDescriptorList);
}
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginBoblight::setupDevice(Device *device)
{
if (!m_bobClient->connected()) {
return reportDeviceSetup(DeviceManager::DeviceSetupStatusFailure, "Cannot connect to Boblight");
}
m_bobClient->currentColor(device->paramValue("channel").toInt());
return reportDeviceSetup();
}
QString DevicePluginBoblight::pluginName() const
{
return "Boblight client";
}
PluginId DevicePluginBoblight::pluginId() const
{
return boblightPluginUuid;
}
QList<ParamType> DevicePluginBoblight::configurationDescription() const
{
QList<ParamType> params;
params.append(ParamType("boblighthost", QVariant::String, "localhost"));
params.append(ParamType("boblightport", QVariant::String, "19333"));
return params;
}
QPair<DeviceManager::DeviceError, QString> DevicePluginBoblight::executeAction(Device *device, const Action &action)
{
if (!m_bobClient->connected()) {
return report(DeviceManager::DeviceErrorSetupFailed, device->id().toString());
}
QColor newColor = action.param("color").value().value<QColor>();
if (!newColor.isValid()) {
return report(DeviceManager::DeviceErrorActionParameterError, "color");
}
qCDebug(dcBoblight) << "executing boblight action" << newColor;
m_bobClient->setColor(device->paramValue("channel").toInt(), newColor);
m_bobClient->sync();
device->setStateValue(colorStateTypeId, newColor);
return report();
}
void DevicePluginBoblight::connectToBoblight()
{
if (configValue("boblighthost").isValid() && configValue("boblightport").isValid()) {
m_bobClient->connect(configValue("boblighthost").toString(), configValue("boblightport").toInt());
}
}

View File

@ -1,61 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2015 Simon Stuerz <simon.stuerz@guh.guru> *
* Copyright (C) 2014 Michael Zanetti <michael_zanetti@gmx.net> *
* *
* This file is part of guh. *
* *
* Guh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, version 2 of the License. *
* *
* Guh is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef DEVICEPLUGINBOBLIGHT_H
#define DEVICEPLUGINBOBLIGHT_H
#include "plugin/deviceplugin.h"
#include <QProcess>
class BobClient;
class DevicePluginBoblight : public DevicePlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "guru.guh.DevicePlugin" FILE "devicepluginboblight.json")
Q_INTERFACES(DevicePlugin)
public:
explicit DevicePluginBoblight();
DeviceManager::HardwareResources requiredHardware() const override;
void startMonitoringAutoDevices() override;
QPair<DeviceManager::DeviceSetupStatus, QString> setupDevice(Device *device) override;
QString pluginName() const override;
PluginId pluginId() const override;
QList<ParamType> configurationDescription() const override;
public slots:
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action);
private slots:
void connectToBoblight();
private:
BobClient *m_bobClient;
};
#endif // DEVICEPLUGINBOBLIGHT_H

View File

@ -1,29 +0,0 @@
{
"id": "8c5e8d4c-b5ed-4bfe-b30d-35c2790ec100",
"name": "Boblight",
"idName": "Boblight",
"vendors": [
{
"name": "Boblight",
"id": "e1647872-c0f5-4680-b49b-3924e5b54dcd",
"deviceClasses": [
{
"deviceClassId": "1647c61c-db14-461e-8060-8a3533d5d92f",
"idName": "boblight",
"name": "Boblight",
"createMethods": ["auto"],
"stateTypes": [
{
"id": "97ec80cd-43a9-40fa-93b7-d1580043d981",
"idName": "color",
"name": "color",
"type": "QColor",
"defaultValue": "#000000",
"writable": {}
}
]
}
]
}
]
}

View File

@ -22,13 +22,3 @@ SUBDIRS += elro \
awattar \
netatmo \
#osdomotics \
boblight {
SUBDIRS += boblight
}
contains(DEFINES, BLUETOOTH_LE) {
SUBDIRS += elgato
}

View File

@ -4,9 +4,6 @@ TARGET = $$qtLibraryTarget(guh_devicepluginlircd)
QT += network
#INCLUDEPATH += /usr/local/include/
#LIBS += -L/usr/local/lib/libboblight.a
SOURCES += \
devicepluginlircd.cpp \
lircdclient.cpp \

View File

@ -19,15 +19,6 @@ SOURCES += main.cpp \
guhservice.cpp \
guhapplication.cpp
boblight {
xcompile {
LIBS += -L../plugins/deviceplugins/boblight -lguh_devicepluginboblight -lboblight
} else {
LIBS += -L../plugins/deviceplugins/boblight -lguh_devicepluginboblight -L/usr/local/lib/ -lboblight
}
DEFINES += USE_BOBLIGHT
}
HEADERS += \
guhservice.h \
guhapplication.h