Commit 2fcfdc07 authored by golgoj4's avatar golgoj4

refs #1767 - Update hue controller.

parent 04ba0946
This diff is collapsed.
......@@ -49,7 +49,8 @@ SOURCES += ../Main.cpp \
../HueController.cpp \
huecontrollerhardware.cpp \
huebulb.cpp \
../huecommand.cpp
../huecommand.cpp \
abstractwirelessbulb.cpp
HEADERS += ../../PlutoUtils/ThreadedClass.h \
../../PlutoUtils/MultiThreadIncludes.h \
......@@ -75,4 +76,5 @@ HEADERS += ../../PlutoUtils/ThreadedClass.h \
../HueController.h \
huecontrollerhardware.h \
huebulb.h \
../huecommand.h
../huecommand.h \
abstractwirelessbulb.h
#include "abstractwirelessbulb.h"
#include "qdebug.h"
AbstractWirelessBulb::AbstractWirelessBulb(HueControllerHardware *p_controller, QObject *parent) : QObject(parent), mp_controller(p_controller)
{
qDebug() << Q_FUNC_INFO << "ctor";
if(mp_controller){
qDebug() << Q_FUNC_INFO << mp_controller->getIpAddress();
} else {
qDebug() << Q_FUNC_INFO << "invalid controller!";
}
}
QString AbstractWirelessBulb::displayName() const
{
return ms_displayName;
}
void AbstractWirelessBulb::setDisplayName(const QString &value)
{
if(ms_displayName==value) return;
ms_displayName= value;
emit displayNameChanged();
}
QString AbstractWirelessBulb::serialNumber() const
{
return ms_serialNumber;
}
void AbstractWirelessBulb::setSerialNumber(const QString &s)
{
if(ms_serialNumber== s)return;
ms_serialNumber=s;
emit serialNumberChanged();
}
QColor AbstractWirelessBulb::color() const
{
return m_color;
}
void AbstractWirelessBulb::setColor(const QColor &color)
{
if(m_color==color) return;
m_color = color;
emit colorChanged();
}
int AbstractWirelessBulb::id()
{
return m_id;
}
void AbstractWirelessBulb::setId( int id)
{
if(m_id==id) return;
m_id = id;
emit idChanged();
}
double AbstractWirelessBulb::CurrentLevel() const
{
return m_CurrentLevel;
}
void AbstractWirelessBulb::setCurrentLevel(double CurrentLevel)
{
if(m_CurrentLevel == CurrentLevel) return;
m_CurrentLevel = CurrentLevel;
emit currentLevelChanged();
}
bool AbstractWirelessBulb::powerOn() const
{
return m_powerOn;
}
void AbstractWirelessBulb::setPowerOn(bool powerOn)
{
if(m_powerOn == powerOn) return;
m_powerOn = powerOn;
emit powerOnChanged();
}
int AbstractWirelessBulb::bulbType() const
{
return m_bulbType;
}
void AbstractWirelessBulb::setBulbType(int bulbType)
{
if(m_bulbType==bulbType) return;
m_bulbType = bulbType;
emit bulbTypeChanged();
}
QString AbstractWirelessBulb::effect() const
{
return m_effect;
}
void AbstractWirelessBulb::setEffect(const QString &effect)
{
if(m_effect==effect);return;
m_effect = effect;
emit effectChanged();
}
QString AbstractWirelessBulb::alert() const
{
return m_alert;
}
void AbstractWirelessBulb::setAlert(const QString &alert)
{
if(m_alert==alert) return;
m_alert = alert;
emit alertChanged();
}
bool AbstractWirelessBulb::online() const
{
return m_online;
}
void AbstractWirelessBulb::setOnline(bool online)
{
if(m_online==online)return;
m_online = online;
emit onlineChanged();
}
HueControllerHardware *AbstractWirelessBulb::getController()
{
return mp_controller;
}
void AbstractWirelessBulb::setController(HueControllerHardware *c)
{
mp_controller=c;
}
QString AbstractWirelessBulb::getUniqueId() const
{
return m_uniqueId;
}
void AbstractWirelessBulb::setUniqueId(const QString &uniqueId)
{
m_uniqueId = uniqueId;
emit uniqueIdChanged();
}
QString AbstractWirelessBulb::getManufacturerName() const
{
return m_manufacturerName;
}
void AbstractWirelessBulb::setManufacturerName(const QString &manufacturerName)
{
m_manufacturerName = manufacturerName;
emit manufacturerChanged();
}
QString AbstractWirelessBulb::getSoftwareVersion() const
{
return m_softwareVersion;
}
void AbstractWirelessBulb::setSoftwareVersion(const QString &softwareVersion)
{
m_softwareVersion = softwareVersion;
emit softwareVersionChanged();
}
QString AbstractWirelessBulb::getLightModel() const
{
return m_lightModel;
}
void AbstractWirelessBulb::setLightModel(const QString &lightModel)
{
m_lightModel = lightModel;
emit lightModelChanged();
}
int AbstractWirelessBulb::linuxmceId() const
{
return m_linuxmceId;
}
void AbstractWirelessBulb::setLinuxmceId(int value)
{
m_linuxmceId = value;
emit linuxmceIdChanged();
}
#ifndef ABSTRACTWIRELESSBULB_H
#define ABSTRACTWIRELESSBULB_H
#include <QObject>
#include <qcolor.h>
#include <qmap.h>
#include "huecontrollerhardware.h"
class AbstractWirelessBulb : public QObject
{
Q_OBJECT
public:
explicit AbstractWirelessBulb(HueControllerHardware* p_controller, QObject *parent = 0);
AbstractWirelessBulb() {}
enum BulbType{
PHILLIPS_HUE,
PHILLIPS_HUE_LUX,
PHILLIPS_HUE_LIGHTSTRIPS,
PHILLIPS_HUE_BLOOM,
CREE_WIRELESS_LED
};
enum alert {
NOALERT,BLINK,FLASH
};
enum effect {
NOEFFECT,COLORLOOP
};
enum colormode{
HUESAT,COLORTEMP,XY
};
QString displayName() const;
void setDisplayName(const QString &value);
QString serialNumber() const;
void setSerialNumber(const QString &s);
QColor color() const;
void setColor(const QColor &color);
int id();
void setId( int id);
double CurrentLevel() const;
void setCurrentLevel(double CurrentLevel);
bool powerOn() const;
void setPowerOn(bool powerOn);
int bulbType() const;
void setBulbType(int bulbType);
QString effect() const;
void setEffect(const QString &effect);
QString alert() const;
void setAlert(const QString &alert);
bool online() const;
void setOnline(bool online);
int linuxmceId() const;
void setLinuxmceId(int value);
QString getLightModel() const;
void setLightModel(const QString &lightModel);
QString getSoftwareVersion() const;
void setSoftwareVersion(const QString &softwareVersion);
QString getManufacturerName() const;
void setManufacturerName(const QString &manufacturerName);
QString getUniqueId() const;
void setUniqueId(const QString &uniqueId);
signals:
void serialNumberChanged();
void displayNameChanged();
void colorChanged();
void idChanged();
void powerOnChanged();
void alertChanged();
void effectChanged();
void bulbTypeChanged();
void onlineChanged();
void currentLevelChanged();
void linuxmceIdChanged();
void lightModelChanged();
void softwareVersionChanged();
void manufacturerChanged();
void uniqueIdChanged();
public slots:
HueControllerHardware * getController();
void setController(HueControllerHardware * c);
private:
QString m_lightModel;
QString ms_serialNumber;
QString ms_displayName;
QString m_softwareVersion;
QString m_manufacturerName;
QString m_uniqueId;
quint8 m_brightness;
quint16 m_hue;
quint8 m_saturation;
QMap<QString, float>xy;
QColor m_color;
int m_id;
int m_linuxmceId;
double m_CurrentLevel;
bool m_powerOn;
int m_bulbType;
QString m_effect;
QString m_alert;
bool m_online;
HueControllerHardware *mp_controller;
QMap<QString, int> deviceMap;
};
#endif // ABSTRACTWIRELESSBULB_H
#include "huebulb.h"
HueBulb::HueBulb(QObject *parent) :
QObject(parent)
HueBulb::HueBulb(HueControllerHardware *hw)
{
powerState="";
int lightId =0 ;
int linuxmceId =0;
QString powerState = "";
quint8 bri = 0;
quint16 hue =0;
quint8 sat = 0;
QMap<QString*, float> xy;
quint16 colorTemp = 0;
QString alertStatus = "";
QString effectStatus ="";
QString currentColorMode = "";
bool reachable = true;
QString lightType = "";
QString lightName = "";
QString modelId = "";
QString swVersion = "";
QString controller= "";
setController(hw);
}
......@@ -22,51 +22,20 @@
#include <QObject>
#include <QMap>
#include <abstractwirelessbulb.h>
class HueBulb : public QObject
class HueBulb : public AbstractWirelessBulb
{
Q_OBJECT
public:
explicit HueBulb(QObject *parent = 0);
enum alert {
NOALERT,BLINK,FLASH
};
enum effect {
NOEFFECT,COLORLOOP
};
enum colormode{
HUESAT,COLORTEMP,XY
};
int lightId;
int linuxmceId;
QString powerState;
quint8 bri;
quint16 hue;
quint8 sat;
QMap<QString*, float> xy;
quint16 colorTemp;
QString alertStatus;
QString effectStatus;
QString currentColorMode;
bool reachable;
QString lightType;
QString lightName;
QString modelId;
QString swVersion;
QString controller;
explicit HueBulb(HueControllerHardware *hw);
HueBulb(){}
signals:
public slots:
int getInternalId() {return lightId;}
int getLinuxMceId() {return linuxmceId;}
QString getController() {return controller;}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment