Removed function

bool devHasMethod(int id, int method)
and replaced with
int devMethods(int id)
This commit is contained in:
Micke Prag 2008-02-08 15:52:06 +00:00
parent be464c4efc
commit 08c02530a6
13 changed files with 26 additions and 58 deletions

View file

@ -45,8 +45,8 @@ void Device::dim(unsigned char level){
} }
/* /*
* Has Method, virtual * Methods, virtual
*/ */
bool Device::hasMethod(int methodname, char* strModel){ int Device::methods(char* strModel){
return false; return 0;
} }

View file

@ -14,7 +14,7 @@ public:
virtual void turnOff(void); virtual void turnOff(void);
virtual void bell(void); virtual void bell(void);
virtual void dim(unsigned char level); virtual void dim(unsigned char level);
virtual bool hasMethod(int methodname, char* strModel); virtual int methods(char* strModel);
static int getDongleIndex(); static int getDongleIndex();
static void debugLog(char* debugstring); static void debugLog(char* debugstring);

View file

@ -130,12 +130,10 @@ string DeviceIkea::getStringCode(unsigned char level){
/* /*
* Has the device got the method? * Has the device got the method?
*/ */
bool DeviceIkea::hasMethod(int methodname, char* strModel){ int DeviceIkea::methods(char* strModel){
if(strcmp(strModel, TELLSTICK_DEVICE_KOPPLA) == 0) { if(strcmp(strModel, TELLSTICK_DEVICE_KOPPLA) == 0) {
if(methodname == TELLSTICK_TURNON || methodname == TELLSTICK_TURNOFF || methodname == TELLSTICK_DIM){ return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM);
return true;
}
} }
return false; return 0;
} }

View file

@ -9,7 +9,7 @@ public:
virtual void turnOn(void); virtual void turnOn(void);
virtual void turnOff(void); virtual void turnOff(void);
virtual void dim(unsigned char level); virtual void dim(unsigned char level);
virtual bool hasMethod(int methodname, char* strModel); virtual int methods(char* strModel);
public: public:
~DeviceIkea(void); ~DeviceIkea(void);

View file

@ -132,7 +132,7 @@ string DeviceNexa::getStringCode(int intToConvert){
/* /*
* Has the device got the method? * Has the device got the method?
*/ */
bool DeviceNexa::hasMethod(int methodname, char* strModel){ int DeviceNexa::methods(char* strModel){
if( strcmp(strModel, TELLSTICK_DEVICE_YCR3500) == 0 || if( strcmp(strModel, TELLSTICK_DEVICE_YCR3500) == 0 ||
strcmp(strModel, TELLSTICK_DEVICE_YCR300D) == 0 || strcmp(strModel, TELLSTICK_DEVICE_YCR300D) == 0 ||
@ -151,13 +151,9 @@ bool DeviceNexa::hasMethod(int methodname, char* strModel){
strcmp(strModel, TELLSTICK_DEVICE_EL2010) == 0 strcmp(strModel, TELLSTICK_DEVICE_EL2010) == 0
) )
{ {
if(methodname == TELLSTICK_TURNON || methodname == TELLSTICK_TURNOFF){ return (TELLSTICK_TURNON | TELLSTICK_TURNOFF);
return true;
}
} else if ( strcmp(strModel, TELLSTICK_DEVICE_ML7100) == 0 ) { } else if ( strcmp(strModel, TELLSTICK_DEVICE_ML7100) == 0 ) {
if(methodname == TELLSTICK_BELL) { return TELLSTICK_BELL;
return true;
}
} }
return false; return 0;
} }

View file

@ -9,7 +9,7 @@ public:
virtual void turnOn(void); virtual void turnOn(void);
virtual void turnOff(void); virtual void turnOff(void);
virtual void bell(void); virtual void bell(void);
virtual bool hasMethod(int methodname, char* strModel); virtual int methods(char* strModel);
public: public:
~DeviceNexa(void); ~DeviceNexa(void);

View file

@ -72,21 +72,8 @@ void DeviceSartano::turnOff(void){
/* /*
* Has the device got the method? * Has the device got the method?
*/ */
bool DeviceSartano::hasMethod(int methodname, char* strModel){ int DeviceSartano::methods(char* strModel){
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF);
bool blnExists = false;
try{
// if(strModel == "xxxx" || strModel == "yyyy"){
if(methodname == TELLSTICK_TURNON || methodname == TELLSTICK_TURNOFF){
blnExists = true;
// }
}
}
catch(...){
throw;
}
return blnExists;
} }
/* /*

View file

@ -9,7 +9,7 @@ public:
DeviceSartano(int intSystem, int intCode, int intDeviceIndex); DeviceSartano(int intSystem, int intCode, int intDeviceIndex);
virtual void turnOn(void); virtual void turnOn(void);
virtual void turnOff(void); virtual void turnOff(void);
virtual bool hasMethod(int methodname, char* strModel); virtual int methods(char* strModel);
~DeviceSartano(void); ~DeviceSartano(void);

View file

@ -40,19 +40,6 @@ void DeviceWaveman::turnOff(void){
/* /*
* Has the device got the method? * Has the device got the method?
*/ */
bool DeviceWaveman::hasMethod(int methodname, char* strModel){ int DeviceWaveman::methods(char* strModel){
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF);
bool blnExists = false;
try{
// if(strModel == "xxxx" || strModel == "yyyy"){
if(methodname == TELLSTICK_TURNON || methodname == TELLSTICK_TURNOFF){
blnExists = true;
// }
}
}
catch(...){
throw;
}
return blnExists;
} }

View file

@ -7,5 +7,5 @@ class DeviceWaveman : public DeviceNexa
public: public:
DeviceWaveman(int intHouse, int intCode, int intDeviceIndex); DeviceWaveman(int intHouse, int intCode, int intDeviceIndex);
virtual void turnOff(void); virtual void turnOff(void);
virtual bool hasMethod(int methodname, char* strModel); virtual int methods(char* strModel);
}; };

View file

@ -285,22 +285,22 @@ bool __stdcall devRemoveDevice(int intDeviceId){
return blnSuccess; return blnSuccess;
} }
bool __stdcall devHasMethod(int id, int methodname){ int __stdcall devMethods(int id){
bool blnExists = false; int intMethods = 0;
try{ try{
TelldusSettings ts; TelldusSettings ts;
char* strModel = ts.getModel(id); char* strModel = ts.getModel(id);
Device* dev = ts.getDevice(id); Device* dev = ts.getDevice(id);
if (dev != NULL) { if (dev != NULL) {
blnExists = dev->hasMethod(methodname, strModel); intMethods = dev->methods(strModel);
} }
} }
catch(exception e){ catch(exception e){
blnExists = false; intMethods = 0;
handleException(e); handleException(e);
} }
return blnExists; return intMethods;
} }

View file

@ -17,7 +17,7 @@ EXPORTS
devAddDevice @12 devAddDevice @12
devRemoveDevice @13 devRemoveDevice @13
devHasMethod @14 devMethods @14
devTurnOn @16 devTurnOn @16
devTurnOff @17 devTurnOff @17
devBell @18 devBell @18

View file

@ -40,7 +40,7 @@ extern "C" {
TELLSTICK_API int WINAPI devAddDeviceWithArguments(char* strVendor, int* intArguments[], int intNumberOfArguments); TELLSTICK_API int WINAPI devAddDeviceWithArguments(char* strVendor, int* intArguments[], int intNumberOfArguments);
TELLSTICK_API bool WINAPI devRemoveDevice(int intDeviceId); TELLSTICK_API bool WINAPI devRemoveDevice(int intDeviceId);
TELLSTICK_API int WINAPI devGetDeviceId(int intDeviceIndex); TELLSTICK_API int WINAPI devGetDeviceId(int intDeviceIndex);
TELLSTICK_API bool WINAPI devHasMethod(int id, int methodname); TELLSTICK_API int WINAPI devMethods(int id);
} }
#define TELLSTICK_TURNON 1 #define TELLSTICK_TURNON 1