Commit 77df4ed1 authored by golgoj4's avatar golgoj4

refs #2302 - another attempt to see how hue controller does.

parent b301a482
......@@ -32,39 +32,41 @@ using namespace DCE;
#include <qnetworkrequest.h>
#include <qeventloop.h>
#include <QVariantMap>
#include <QApplication>
#include <Qt/qapplication.h>
#include <QStringList>
#include <huecontrollerhardware.h>
#include <huebulb.h>
#include <pthread.h>
#include <QColor>
#include <QtGui/QColor>
#include <math.h>
//<-dceag-const-b->
// The primary constructor when the class is created as a stand-alone device
HueController::HueController(int DeviceID, string ServerAddress, bool bConnectEventHandler, bool bLocalMode, class Router *pRouter,QObject*parent)
: DCE::HueController_Command(DeviceID, ServerAddress,bConnectEventHandler,bLocalMode,pRouter)
: DCE::HueController_Command(DeviceID, ServerAddress,bConnectEventHandler,bLocalMode,pRouter),
mb_isNew(true),
triesLeft(6),
linkButton(false),
validated(false),
linkButtonManager(new QNetworkAccessManager()),
commandManager(new QNetworkAccessManager()),
targetIpAddress(""),
authUser(""),
linkButtonTimer(new QTimer())
//<-dceag-const-e->
{
LoggerWrapper::GetInstance()->Write(LV_WARNING, "HueController, Device %d is alive!", this->m_dwPK_Device);
authUser ="";
triesLeft=6;
linkButton=false;
mb_isNew=true;
linkButtonManager = new QNetworkAccessManager();
// QObject::connect(this, SIGNAL(initiateConfigDownload()), this, SLOT(getHueDataStore()), Qt::DirectConnection);
// QObject::connect(this, SIGNAL(initiateConfigDownload()), this, SLOT(dummySlot()));
//QObject::connect(this,SIGNAL(testSignal()), this, SLOT(dummySlot()));
linkButtonTimer = new QTimer();
linkButtonTimer->setInterval(3000);
QObject::connect(linkButtonTimer, SIGNAL(timeout()), this, SLOT(checkLinkButton()));
linkButtonTimer->setSingleShot(false);
// pthread_yield();
}
//<-dceag-const2-b->
......@@ -996,22 +998,20 @@ bool HueController::sendPowerMessage(QUrl message, QVariant params)
{
// LoggerWrapper::GetInstance()->Write(LV_STATUS, "Sending Message:: %s ",message.toString(), params.toString());
qDebug() << "state message::"<<message;
QNetworkAccessManager * cmdMgr = new QNetworkAccessManager();
QNetworkRequest pr(message);
QJson::Serializer serializer;
QByteArray serialized = serializer.serialize(params);
qDebug()<< serialized;
QEventLoop respWait;
QObject::connect(cmdMgr, SIGNAL(finished(QNetworkReply*)), &respWait, SLOT(quit()));
QNetworkReply * ptx = cmdMgr->put(pr, serialized);
QObject::connect(commandManager, SIGNAL(finished(QNetworkReply*)), &respWait, SLOT(quit()));
QNetworkReply * ptx = commandManager->put(pr, serialized);
cout << "Waiting for Response" << endl;
respWait.exec();
qDebug()<< "Got Response";
qDebug() << ptx->readAll();
pr.~QNetworkRequest();
qDebug() << ptx->readAll();
ptx->deleteLater();
cmdMgr->deleteLater();
/* Need to start returning status here */
return true;
}
......
......@@ -35,24 +35,11 @@ class HueController : public HueController_Command
{
Q_OBJECT
//<-dceag-decl-e->
// Private member variables
bool mb_isNew;
bool validated;
bool linkButton;
int triesLeft;
QString targetIpAddress;
QString authUser;
QList<HueControllerHardware*> hueControllers;
QList<HueBulb*> hueBulbs;
QNetworkAccessManager * linkButtonManager;
QNetworkAccessManager * commandManager;
QTimer *linkButtonTimer;
// Private methods
public:
// Public member variables
QList<HueControllerHardware*> hueControllers;
QList<HueBulb*> hueBulbs;
//<-dceag-const-b->
......@@ -65,20 +52,17 @@ public:
virtual void ReceivedCommandForChild(DeviceData_Impl *pDeviceData_Impl,string &sCMD_Result,Message *pMessage);
virtual void ReceivedUnknownCommand(string &sCMD_Result,Message *pMessage);
virtual void CreateChildren();
virtual void OnReload();
//<-dceag-const-e->
//<-dceag-const-e->
void initBridgeConnection();
bool findControllers();
bool downloadControllerConfig(QUrl deviceIp, int index);
void getScreenSaverColor();
bool setupController(int controllerIndex);
virtual void OnReload();
void setDeviceStatus(int device, QString status);
//<-dceag-const2-b->
// The following constructor is only used if this a class instance embedded within a DCE Device. In that case, it won't create it's own connection to the router
// You can delete this whole section and put an ! after dceag-const2-b tag if you don't want this constructor. Do the same in the implementation file
......@@ -219,6 +203,19 @@ public slots:
protected:
bool sendPowerMessage(QUrl message, QVariant params);
private:
QNetworkAccessManager * linkButtonManager;
QNetworkAccessManager * commandManager;
bool mb_isNew;
bool validated;
bool linkButton;
int triesLeft;
QString targetIpAddress;
QString authUser;
QTimer *linkButtonTimer;
};
//<-dceag-end-b->
......
# -------------------------------------------------
# Project created by QtCreator 2013-05-04T14:36:21
# -------------------------------------------------
QT += core network
QT += gui
QT += core network gui
TARGET = HueController
......
......@@ -258,6 +258,12 @@ QMAKE_CXXFLAGS += -DUSE_LZO_DATAGRID
#LinuxMCE Specific include path. Linking in the app instead of against dce libs for multi-platform expediency.
INCLUDEPATH += ../../ ../../DCE/
noqrc{
DEFINES+=NOQRC
} else {
RESOURCES+=qmlFile.qrc
}
!macx{
......@@ -545,13 +551,10 @@ for_harmattan{
RESOURCES += \
skinData.qrc \
qmlFile.qrc
skinData.qrc
no-qrc{
DEFINES+=NOQRC
RESOURCES-=qmlFile.qrc
}
......@@ -9,10 +9,6 @@ Item {
id:layout
anchors.fill: qmlRoot
Rectangle{
anchors.fill: parent
color:"transparent"
}
property bool uiOn:true
property alias scenarioModel:current_scenarios.model
......
......@@ -16,6 +16,11 @@ Item{
property int switchTimer:20000
readonly property int transitionTime:switchTimer-4500
Rectangle{
anchors.fill: parent
color:"black"
}
Component.onCompleted: loadImageList()
Connections{
......
......@@ -1857,9 +1857,9 @@ private slots:
}
qorbiterUIwin->engine()->rootContext()->setContextProperty("Style", m_style);
QString returnLocation=qorbiterUIwin->source().toString();
qorbiterUIwin->engine()->clearComponentCache();
#ifdef simulate
qorbiterUIwin->setSource(QUrl(m_selector->select(m_localQmlPath+"Index.qml")));
qorbiterUIwin->engine()->clearComponentCache();
#else
qorbiterUIwin->setSource(QUrl("qrc:/qml/qml/Index.qml"));
......
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