Added protocol Brateck
This commit is contained in:
parent
579f42568e
commit
bd97d86164
4 changed files with 59 additions and 7 deletions
|
@ -16,6 +16,8 @@ SET( telldus-service_SRCS
|
|||
SET( telldus-service_protocol_SRCS
|
||||
Protocol.h
|
||||
Protocol.cpp
|
||||
ProtocolBrateck.h
|
||||
ProtocolBrateck.cpp
|
||||
ProtocolNexa.h
|
||||
ProtocolNexa.cpp
|
||||
)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include "Protocol.h"
|
||||
#include "../client/telldus-core.h"
|
||||
|
||||
#include "ProtocolBrateck.h"
|
||||
#include "ProtocolNexa.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
@ -82,15 +84,11 @@ Protocol *Protocol::getProtocolInstance(std::wstring &protocolname){
|
|||
|
||||
if(comparei(protocolname, L"arctech")){
|
||||
return new ProtocolNexa();
|
||||
//((ProtocolNexa*)prot)->setHouse(settings.getDeviceParameter(deviceId, "house"));
|
||||
//((ProtocolNexa*)prot)->setUnit(settings.getDeviceParameter(deviceId, "unit"));
|
||||
|
||||
}
|
||||
/*else if (wcscasecmp(protocolname.c_str(), L"brateck") == 0) {
|
||||
prot = new ProtocolBrateck(deviceId, modelname);
|
||||
((ProtocolBrateck*)prot)->setHouse(settings.getDeviceParameter(deviceId, "house"));
|
||||
} else if (comparei(protocolname, L"brateck")) {
|
||||
return new ProtocolBrateck();
|
||||
|
||||
} else if (wcscasecmp(protocolname.c_str(), L"everflourish") == 0){
|
||||
} /*else if (wcscasecmp(protocolname.c_str(), L"everflourish") == 0){
|
||||
prot = new ProtocolEverflourish(deviceId, modelname);
|
||||
((ProtocolEverflourish*)prot)->setHouse(settings.getDeviceParameter(deviceId, "house"));
|
||||
((ProtocolEverflourish*)prot)->setUnit(settings.getDeviceParameter(deviceId, "unit"));
|
||||
|
|
40
telldus-core/service/ProtocolBrateck.cpp
Normal file
40
telldus-core/service/ProtocolBrateck.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include "ProtocolBrateck.h"
|
||||
|
||||
std::string ProtocolBrateck::getStringForMethod(int method, const std::string &, Controller *) {
|
||||
const char S = '!';
|
||||
const char L = 'V';
|
||||
const char B1[] = {L,S,L,S,0};
|
||||
const char BX[] = {S,L,L,S,0};
|
||||
const char B0[] = {S,L,S,L,0};
|
||||
const char BUP[] = {L,S,L,S,S,L,S,L,S,L,S,L,S,L,S,L,S,0};
|
||||
const char BSTOP[] = {S,L,S,L,L,S,L,S,S,L,S,L,S,L,S,L,S,0};
|
||||
const char BDOWN[] = {S,L,S,L,S,L,S,L,S,L,S,L,L,S,L,S,S,0};
|
||||
|
||||
std::string strReturn;
|
||||
std::wstring strHouse = this->getStringParameter(L"house", L"");
|
||||
if (strHouse == L"") {
|
||||
return "";
|
||||
}
|
||||
|
||||
for( size_t i = 0; i < strHouse.length(); ++i ) {
|
||||
if (strHouse[i] == '1') {
|
||||
strReturn.insert(0, B1);
|
||||
} else if (strHouse[i] == '-') {
|
||||
strReturn.insert(0, BX);
|
||||
} else if (strHouse[i] == '0') {
|
||||
strReturn.insert(0, B0);
|
||||
}
|
||||
}
|
||||
|
||||
strReturn.insert(0, "S");
|
||||
if (method == TELLSTICK_TURNON) {
|
||||
strReturn.append(BUP);
|
||||
} else if (method == TELLSTICK_TURNOFF) {
|
||||
strReturn.append(BDOWN);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
strReturn.append("+");
|
||||
|
||||
return strReturn;
|
||||
}
|
12
telldus-core/service/ProtocolBrateck.h
Normal file
12
telldus-core/service/ProtocolBrateck.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef PROTOCOLBRATECK_H
|
||||
#define PROTOCOLBRATECK_H
|
||||
|
||||
#include "Protocol.h"
|
||||
|
||||
class ProtocolBrateck : public Protocol
|
||||
{
|
||||
public:
|
||||
virtual std::string getStringForMethod(int method, const std::string &data, Controller *controller);
|
||||
};
|
||||
|
||||
#endif //PROTOCOLBRATECK_H
|
Loading…
Add table
Add a link
Reference in a new issue