Commit 28a09ed3 authored by golgoj4's avatar golgoj4

refs

parent 34bde6b9
# -------------------------------------------------
# Project created by QtCreator 2013-05-04T14:36:21
# -------------------------------------------------
QT += network \
script
QT -= gui
TARGET = HueController
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
INCLUDEPATH += /usr/include/qjson/ \
../../ \
../../DCE/
SOURCES += ../Main.cpp \
../../PlutoUtils/uuencode.cpp \
../../PlutoUtils/ThreadedClass.cpp \
../../PlutoUtils/Other.cpp \
../../PlutoUtils/MultiThreadIncludes.cpp \
../../PlutoUtils/minilzo.cpp \
../../PlutoUtils/md5c.cpp \
../../PlutoUtils/FileUtils.cpp \
../../PlutoUtils/CommonIncludes.cpp \
../../SerializeClass/SerializeClass.cpp \
../../DCE/Virtual_Device_Translator.cpp \
../../DCE/Socket.cpp \
../../DCE/ServerLogger.cpp \
../../DCE/PlainClientSocket.cpp \
../../DCE/MessageBuffer.cpp \
../../DCE/Message.cpp \
../../DCE/HandleRequestSocket.cpp \
../../DCE/Logger.cpp \
../../DCE/Event_Impl.cpp \
../../DCE/DCEConfig.cpp \
../../DCE/DataGrid.cpp \
../../DCE/Command_Impl.cpp \
../../DCE/AlarmManager.cpp \
../../PlutoUtils/StringUtils.cpp \
../../DCE/ClientSocket.cpp \
../../DCE/DeviceData_Base.cpp \
../../DCE/DeviceData_Impl.cpp \
../../PlutoUtils/getch.cpp \
../../Gen_Devices/Hue_ControllerBase.cpp \
../Hue_Controller.cpp \
huebridge.cpp
HEADERS += ../../PlutoUtils/ThreadedClass.h \
../../PlutoUtils/MultiThreadIncludes.h \
../../PlutoUtils/StringUtils.h \
../../PlutoUtils/CommonIncludes.h \
../../PlutoUtils/Other.h \
../../PlutoUtils/getch.h \
../../PlutoUtils/MyStl.h \
../../DCE/DeviceData_Base.h \
../../DCE/Message.h \
../../DCE/ServerLogger.h \
../../DCE/Logger.h \
../../DCE/Virtual_Device_Translator.h \
../../DCE/PlutoLockLogger.h \
../../DCE/ClientSocket.h \
../../DCE/PlainClientSocket.h \
../../DCE/AlarmManager.h \
../../SerializeClass/SerializeClass.h \
../../PlutoUtils/FileUtils.h \
../../pluto_main/Define_DeviceCategory.h \
../../pluto_main/Define_DeviceTemplate.h \
../../Gen_Devices/Hue_ControllerBase.h \
../Hue_Controller.h \
huebridge.h
This diff is collapsed.
#include "huebridge.h"
HueBridge::HueBridge(QObject *parent) :
QObject(parent)
{
}
#ifndef HUEBRIDGE_H
#define HUEBRIDGE_H
#include <QObject>
class HueBridge : public QObject
{
Q_OBJECT
public:
explicit HueBridge(QObject *parent = 0);
signals:
public slots:
};
#endif // HUEBRIDGE_H
#include <QtCore/QCoreApplication>
int main(int argc, char *argv[])
{
return a.exec();
}
......@@ -25,30 +25,34 @@ using namespace DCE;
#include "Gen_Devices/AllCommandsRequests.h"
//<-dceag-d-e->
#include <QDebug>
#include <qjson/parser.h>
#include <qjson/serializer.h>
//<-dceag-const-b->
// The primary constructor when the class is created as a stand-alone device
Hue_Controller::Hue_Controller(int DeviceID, string ServerAddress,bool bConnectEventHandler,bool bLocalMode,class Router *pRouter)
: Hue_Controller_Command(DeviceID, ServerAddress,bConnectEventHandler,bLocalMode,pRouter)
: Hue_Controller_Command(DeviceID, ServerAddress,bConnectEventHandler,bLocalMode,pRouter)
//<-dceag-const-e->
{
qDebug() << "Created Controller.";
qDebug() << this->thread();
mb_isNew = true;
}
//<-dceag-const2-b->
// The constructor when the class is created as an embedded instance within another stand-alone device
Hue_Controller::Hue_Controller(Command_Impl *pPrimaryDeviceCommand, DeviceData_Impl *pData, Event_Impl *pEvent, Router *pRouter)
: Hue_Controller_Command(pPrimaryDeviceCommand, pData, pEvent, pRouter)
//<-dceag-const2-e->
{
}
//Hue_Controller::Hue_Controller(Command_Impl *pPrimaryDeviceCommand, DeviceData_Impl *pData, Event_Impl *pEvent, Router *pRouter)
// : Hue_Controller_Command(pPrimaryDeviceCommand, pData, pEvent, pRouter, 0)
//////<-dceag-const2-e->
//{
//}
//<-dceag-dest-b->
Hue_Controller::~Hue_Controller()
//<-dceag-dest-e->
{
}
//Hue_Controller::~Hue_Controller()
////<-dceag-dest-e->
//{
//
//}
//<-dceag-getconfig-b->
bool Hue_Controller::GetConfig()
......@@ -57,9 +61,18 @@ bool Hue_Controller::GetConfig()
return false;
//<-dceag-getconfig-e->
// Put your code here to initialize the data in this class
// The configuration parameters DATA_ are now populated
return true;
// Put your code here to initialize the data in this class
// The configuration parameters DATA_ are now populated
QString m_id= QString::fromStdString(this->DATA_Get_Device());
if(m_id.isEmpty()){
qDebug() << "Hue ID is not set, Adding 1st missing hue controller." << m_id;
findLocalControllers();
// DATA_Set_Device("derp", true);
// DATA_Set_Server_IP("foodiddy", true);
}
return true;
}
//<-dceag-reg-b->
......@@ -67,17 +80,17 @@ bool Hue_Controller::GetConfig()
bool Hue_Controller::Register()
//<-dceag-reg-e->
{
return Connect(PK_DeviceTemplate_get());
return Connect(PK_DeviceTemplate_get());
}
/* Since several parents can share the same child class, and each has it's own implementation, the base class in Gen_Devices
cannot include the actual implementation. Instead there's an extern function declared, and the actual new exists here. You
can safely remove this block (put a ! after the dceag-createinst-b block) if this device is not embedded within other devices. */
//<-dceag-createinst-b->
Hue_Controller_Command *Create_Hue_Controller(Command_Impl *pPrimaryDeviceCommand, DeviceData_Impl *pData, Event_Impl *pEvent, Router *pRouter)
{
return new Hue_Controller(pPrimaryDeviceCommand, pData, pEvent, pRouter);
}
//Hue_Controller_Command *Create_Hue_Controller(Command_Impl *pPrimaryDeviceCommand, DeviceData_Impl *pData, Event_Impl *pEvent, Router *pRouter)
//{
// return new Hue_Controller(pPrimaryDeviceCommand, pData, pEvent, pRouter);
//}
//<-dceag-createinst-e->
/*
......@@ -92,7 +105,7 @@ Hue_Controller_Command *Create_Hue_Controller(Command_Impl *pPrimaryDeviceComman
void Hue_Controller::ReceivedCommandForChild(DeviceData_Impl *pDeviceData_Impl,string &sCMD_Result,Message *pMessage)
//<-dceag-cmdch-e->
{
sCMD_Result = "UNHANDLED CHILD";
sCMD_Result = "UNHANDLED CHILD";
}
/*
......@@ -104,7 +117,7 @@ void Hue_Controller::ReceivedCommandForChild(DeviceData_Impl *pDeviceData_Impl,s
void Hue_Controller::ReceivedUnknownCommand(string &sCMD_Result,Message *pMessage)
//<-dceag-cmduk-e->
{
sCMD_Result = "UNKNOWN COMMAND";
sCMD_Result = "UNKNOWN COMMAND";
}
//<-dceag-sample-b->
......@@ -206,8 +219,8 @@ void Hue_Controller::SomeFunction()
void Hue_Controller::CMD_Set_Level(string sLevel,string &sCMD_Result,Message *pMessage)
//<-dceag-c184-e->
{
cout << "Need to implement command #184 - Set Level" << endl;
cout << "Parm #76 - Level=" << sLevel << endl;
cout << "Need to implement command #184 - Set Level" << endl;
cout << "Parm #76 - Level=" << sLevel << endl;
}
//<-dceag-c192-b->
......@@ -222,9 +235,9 @@ void Hue_Controller::CMD_Set_Level(string sLevel,string &sCMD_Result,Message *pM
void Hue_Controller::CMD_On(int iPK_Pipe,string sPK_Device_Pipes,string &sCMD_Result,Message *pMessage)
//<-dceag-c192-e->
{
cout << "Need to implement command #192 - On" << endl;
cout << "Parm #97 - PK_Pipe=" << iPK_Pipe << endl;
cout << "Parm #98 - PK_Device_Pipes=" << sPK_Device_Pipes << endl;
cout << "Need to implement command #192 - On" << endl;
cout << "Parm #97 - PK_Pipe=" << iPK_Pipe << endl;
cout << "Parm #98 - PK_Device_Pipes=" << sPK_Device_Pipes << endl;
}
//<-dceag-c193-b->
......@@ -237,8 +250,8 @@ void Hue_Controller::CMD_On(int iPK_Pipe,string sPK_Device_Pipes,string &sCMD_Re
void Hue_Controller::CMD_Off(int iPK_Pipe,string &sCMD_Result,Message *pMessage)
//<-dceag-c193-e->
{
cout << "Need to implement command #193 - Off" << endl;
cout << "Parm #97 - PK_Pipe=" << iPK_Pipe << endl;
cout << "Need to implement command #193 - Off" << endl;
cout << "Parm #97 - PK_Pipe=" << iPK_Pipe << endl;
}
//<-dceag-c756-b->
......@@ -249,7 +262,7 @@ void Hue_Controller::CMD_Off(int iPK_Pipe,string &sCMD_Result,Message *pMessage)
void Hue_Controller::CMD_Report_Child_Devices(string &sCMD_Result,Message *pMessage)
//<-dceag-c756-e->
{
cout << "Need to implement command #756 - Report Child Devices" << endl;
cout << "Need to implement command #756 - Report Child Devices" << endl;
}
//<-dceag-c757-b->
......@@ -262,8 +275,8 @@ void Hue_Controller::CMD_Report_Child_Devices(string &sCMD_Result,Message *pMess
void Hue_Controller::CMD_Download_Configuration(string sText,string &sCMD_Result,Message *pMessage)
//<-dceag-c757-e->
{
cout << "Need to implement command #757 - Download Configuration" << endl;
cout << "Parm #9 - Text=" << sText << endl;
cout << "Need to implement command #757 - Download Configuration" << endl;
cout << "Parm #9 - Text=" << sText << endl;
}
//<-dceag-c760-b->
......@@ -281,10 +294,10 @@ PK_CommandParameter|Value|... */
void Hue_Controller::CMD_Send_Command_To_Child(string sID,int iPK_Command,string sParameters,string &sCMD_Result,Message *pMessage)
//<-dceag-c760-e->
{
cout << "Need to implement command #760 - Send Command To Child" << endl;
cout << "Parm #10 - ID=" << sID << endl;
cout << "Parm #154 - PK_Command=" << iPK_Command << endl;
cout << "Parm #202 - Parameters=" << sParameters << endl;
cout << "Need to implement command #760 - Send Command To Child" << endl;
cout << "Parm #10 - ID=" << sID << endl;
cout << "Parm #154 - PK_Command=" << iPK_Command << endl;
cout << "Parm #202 - Parameters=" << sParameters << endl;
}
//<-dceag-c776-b->
......@@ -298,8 +311,8 @@ NOEMON or CANBUS */
void Hue_Controller::CMD_Reset(string sArguments,string &sCMD_Result,Message *pMessage)
//<-dceag-c776-e->
{
cout << "Need to implement command #776 - Reset" << endl;
cout << "Parm #51 - Arguments=" << sArguments << endl;
cout << "Need to implement command #776 - Reset" << endl;
cout << "Parm #51 - Arguments=" << sArguments << endl;
}
//<-dceag-c788-b->
......@@ -312,8 +325,8 @@ void Hue_Controller::CMD_Reset(string sArguments,string &sCMD_Result,Message *pM
void Hue_Controller::CMD_StatusReport(string sArguments,string &sCMD_Result,Message *pMessage)
//<-dceag-c788-e->
{
cout << "Need to implement command #788 - StatusReport" << endl;
cout << "Parm #51 - Arguments=" << sArguments << endl;
cout << "Need to implement command #788 - StatusReport" << endl;
cout << "Parm #51 - Arguments=" << sArguments << endl;
}
//<-dceag-c980-b->
......@@ -330,10 +343,15 @@ void Hue_Controller::CMD_StatusReport(string sArguments,string &sCMD_Result,Mess
void Hue_Controller::CMD_Set_Color_RGB(int iRed_Level,int iGreen_Level,int iBlue_Level,string &sCMD_Result,Message *pMessage)
//<-dceag-c980-e->
{
cout << "Need to implement command #980 - Set Color RGB" << endl;
cout << "Parm #279 - Red_Level=" << iRed_Level << endl;
cout << "Parm #280 - Green_Level=" << iGreen_Level << endl;
cout << "Parm #281 - Blue_Level=" << iBlue_Level << endl;
cout << "Need to implement command #980 - Set Color RGB" << endl;
cout << "Parm #279 - Red_Level=" << iRed_Level << endl;
cout << "Parm #280 - Green_Level=" << iGreen_Level << endl;
cout << "Parm #281 - Blue_Level=" << iBlue_Level << endl;
}
bool Hue_Controller::findLocalControllers(){
}
......@@ -23,36 +23,44 @@
#include "qjson/parser.h"
#include "qjson/qobjecthelper.h"
#include "qjson/serializer.h"
#include "qnetworkaccessmanager.h"
//<-dceag-decl-b->
namespace DCE
{
class Hue_Controller : public Hue_Controller_Command , public QObject
{
//<-dceag-decl-e->
// Private member variables
// Private methods
public:
// Public member variables
//<-dceag-const-b->
public:
// Constructors/Destructor
Hue_Controller(int DeviceID, string ServerAddress,bool bConnectEventHandler=true,bool bLocalMode=false,class Router *pRouter=NULL);
virtual ~Hue_Controller();
virtual bool GetConfig();
virtual bool Register();
virtual void ReceivedCommandForChild(DeviceData_Impl *pDeviceData_Impl,string &sCMD_Result,Message *pMessage);
virtual void ReceivedUnknownCommand(string &sCMD_Result,Message *pMessage);
//<-dceag-const-e->
//<-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
Hue_Controller(Command_Impl *pPrimaryDeviceCommand, DeviceData_Impl *pData, Event_Impl *pEvent, Router *pRouter);
//<-dceag-const2-e->
//<-dceag-h-b->
class Hue_Controller : public Hue_Controller_Command, public QObject
{
//<-dceag-decl-e->
// Private member variables
bool mb_isNew;
// Private methods
public:
// Public member variables
//<-dceag-const-b->
public:
// Constructors/Destructor
Hue_Controller(int DeviceID, string ServerAddress,bool bConnectEventHandler=true,bool bLocalMode=false,class Router *pRouter=NULL);
// virtual ~Hue_Controller();
virtual bool GetConfig();
virtual bool Register();
virtual void ReceivedCommandForChild(DeviceData_Impl *pDeviceData_Impl,string &sCMD_Result,Message *pMessage);
virtual void ReceivedUnknownCommand(string &sCMD_Result,Message *pMessage);
bool findLocalControllers();
//<-dceag-const-e->
//<-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
Hue_Controller(Command_Impl *pPrimaryDeviceCommand, DeviceData_Impl *pData, Event_Impl *pEvent, Router *pRouter);
//<-dceag-const2-e->
//<-dceag-h-b->
/*
AUTO-GENERATED SECTION
Do not change the declarations
......@@ -63,6 +71,8 @@ public:
string DATA_Get_Device();
void DATA_Set_Device(string Value,bool bUpdateDatabase=false);
string DATA_Get_Username();
string DATA_Get_Server_IP();
void DATA_Set_Server_IP(string Value,bool bUpdateDatabase=false);
*****EVENT***** accessors inherited from base class
void EVENT_State_Changed(int iValue);
......@@ -73,8 +83,8 @@ public:
/** @brief COMMAND: #184 - Set Level */
/** Sets the brightness of the light. The value is 0 for off, up to 100 for full brightness. Several devices such as Drapes Switch can accept relative levels (+1 to step forward/-1 to step backword). */
/** @param #76 Level */
/** The level to set, as a value between 0 (off) and 100 (full). It can be preceeded with a - or + indicating a relative value. +20 means up 20%. */
/** @param #76 Level */
/** The level to set, as a value between 0 (off) and 100 (full). It can be preceeded with a - or + indicating a relative value. +20 means up 20%. */
virtual void CMD_Set_Level(string sLevel) { string sCMD_Result; CMD_Set_Level(sLevel.c_str(),sCMD_Result,NULL);};
virtual void CMD_Set_Level(string sLevel,string &sCMD_Result,Message *pMessage);
......@@ -82,10 +92,10 @@ public:
/** @brief COMMAND: #192 - On */
/** Turn on the device */
/** @param #97 PK_Pipe */
/** Normally when a device is turned on all the inputs and outputs are selected automatically. If this parameter is specified, only the settings along this pipe will be set. */
/** @param #98 PK_Device_Pipes */
/** Normally when a device is turned on the corresponding "pipes" are enabled by default. if this parameter is blank. If this parameter is 0, no pipes will be enabled. This can also be a comma seperated list of devices, meaning only the pipes to those devic */
/** @param #97 PK_Pipe */
/** Normally when a device is turned on all the inputs and outputs are selected automatically. If this parameter is specified, only the settings along this pipe will be set. */
/** @param #98 PK_Device_Pipes */
/** Normally when a device is turned on the corresponding "pipes" are enabled by default. if this parameter is blank. If this parameter is 0, no pipes will be enabled. This can also be a comma seperated list of devices, meaning only the pipes to those devic */
virtual void CMD_On(int iPK_Pipe,string sPK_Device_Pipes) { string sCMD_Result; CMD_On(iPK_Pipe,sPK_Device_Pipes.c_str(),sCMD_Result,NULL);};
virtual void CMD_On(int iPK_Pipe,string sPK_Device_Pipes,string &sCMD_Result,Message *pMessage);
......@@ -93,8 +103,8 @@ public:
/** @brief COMMAND: #193 - Off */
/** Turn off the device */
/** @param #97 PK_Pipe */
/** Normally when a device is turned on all the inputs and outputs are selected automatically. If this parameter is specified, only the settings along this pipe will be set. */
/** @param #97 PK_Pipe */
/** Normally when a device is turned on all the inputs and outputs are selected automatically. If this parameter is specified, only the settings along this pipe will be set. */
virtual void CMD_Off(int iPK_Pipe) { string sCMD_Result; CMD_Off(iPK_Pipe,sCMD_Result,NULL);};
virtual void CMD_Off(int iPK_Pipe,string &sCMD_Result,Message *pMessage);
......@@ -109,8 +119,8 @@ public:
/** @brief COMMAND: #757 - Download Configuration */
/** Download new configuration data for this device */
/** @param #9 Text */
/** Any information the device may want to do the download */
/** @param #9 Text */
/** Any information the device may want to do the download */
virtual void CMD_Download_Configuration(string sText) { string sCMD_Result; CMD_Download_Configuration(sText.c_str(),sCMD_Result,NULL);};
virtual void CMD_Download_Configuration(string sText,string &sCMD_Result,Message *pMessage);
......@@ -118,12 +128,12 @@ public:
/** @brief COMMAND: #760 - Send Command To Child */
/** After reporting new child devices, there may be children we want to test, but we haven't done a quick reload router and can't send them messages directly. This way we can send 'live' messages to children */
/** @param #10 ID */
/** The internal ID used for this device--not the Pluto device ID. */
/** @param #154 PK_Command */
/** The command to send */
/** @param #202 Parameters */
/** Parameters for the command in the format:
/** @param #10 ID */
/** The internal ID used for this device--not the Pluto device ID. */
/** @param #154 PK_Command */
/** The command to send */
/** @param #202 Parameters */
/** Parameters for the command in the format:
PK_CommandParameter|Value|... */
virtual void CMD_Send_Command_To_Child(string sID,int iPK_Command,string sParameters) { string sCMD_Result; CMD_Send_Command_To_Child(sID.c_str(),iPK_Command,sParameters.c_str(),sCMD_Result,NULL);};
......@@ -132,8 +142,8 @@ PK_CommandParameter|Value|... */
/** @brief COMMAND: #776 - Reset */
/** Reset device. */
/** @param #51 Arguments */
/** Argument string
/** @param #51 Arguments */
/** Argument string
NOEMON or CANBUS */
virtual void CMD_Reset(string sArguments) { string sCMD_Result; CMD_Reset(sArguments.c_str(),sCMD_Result,NULL);};
......@@ -142,8 +152,8 @@ NOEMON or CANBUS */
/** @brief COMMAND: #788 - StatusReport */
/** Test comand. Asq a report */
/** @param #51 Arguments */
/** Argument string */
/** @param #51 Arguments */
/** Argument string */
virtual void CMD_StatusReport(string sArguments) { string sCMD_Result; CMD_StatusReport(sArguments.c_str(),sCMD_Result,NULL);};
virtual void CMD_StatusReport(string sArguments,string &sCMD_Result,Message *pMessage);
......@@ -151,20 +161,25 @@ NOEMON or CANBUS */
/** @brief COMMAND: #980 - Set Color RGB */
/** set the rgb color of a device */
/** @param #279 Red Level */
/** The red level for the device */
/** @param #280 Green Level */
/** The green level for the device */
/** @param #281 Blue Level */
/** The blue level for the device */
/** @param #279 Red Level */
/** The red level for the device */
/** @param #280 Green Level */
/** The green level for the device */
/** @param #281 Blue Level */
/** The blue level for the device */
virtual void CMD_Set_Color_RGB(int iRed_Level,int iGreen_Level,int iBlue_Level) { string sCMD_Result; CMD_Set_Color_RGB(iRed_Level,iGreen_Level,iBlue_Level,sCMD_Result,NULL);};
virtual void CMD_Set_Color_RGB(int iRed_Level,int iGreen_Level,int iBlue_Level,string &sCMD_Result,Message *pMessage);
//<-dceag-h-e->
};
//<-dceag-h-e->
public slots:
void replyFinished(QNetworkReply*);
};
//<-dceag-end-b->
//<-dceag-end-b->
}
#endif
//<-dceag-end-e->
This diff is collapsed.
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