Added class Sensor
This commit is contained in:
parent
281621a4ef
commit
6c48005af2
3 changed files with 65 additions and 0 deletions
|
@ -17,6 +17,7 @@ SET( telldus-service_SRCS
|
|||
Device.cpp
|
||||
DeviceManager.cpp
|
||||
Event.cpp
|
||||
Sensor.cpp
|
||||
Settings.cpp
|
||||
TelldusMain.cpp
|
||||
TellStick.cpp
|
||||
|
@ -67,6 +68,7 @@ SET( telldus-service_HDRS
|
|||
DeviceManager.h
|
||||
Event.h
|
||||
EventHandler.h
|
||||
Sensor.h
|
||||
Settings.h
|
||||
TelldusMain.h
|
||||
TellStick.h
|
||||
|
|
39
telldus-core/service/Sensor.cpp
Normal file
39
telldus-core/service/Sensor.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include "Sensor.h"
|
||||
#include "common.h"
|
||||
|
||||
class Sensor::PrivateData {
|
||||
public:
|
||||
std::wstring protocol, model;
|
||||
int id;
|
||||
time_t timestamp;
|
||||
};
|
||||
|
||||
Sensor::Sensor(const std::wstring &protocol, const std::wstring &model, int id)
|
||||
:Mutex()
|
||||
{
|
||||
d = new PrivateData;
|
||||
d->protocol = protocol;
|
||||
d->model = model;
|
||||
d->id = id;
|
||||
}
|
||||
|
||||
Sensor::~Sensor() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
std::wstring Sensor::protocol() const {
|
||||
return d->protocol;
|
||||
}
|
||||
|
||||
std::wstring Sensor::model() const {
|
||||
return d->model;
|
||||
}
|
||||
|
||||
int Sensor::id() const {
|
||||
return d->id;
|
||||
}
|
||||
|
||||
void Sensor::setValue(const std::string &name, const std::string &value, time_t timestamp) {
|
||||
//TODO: Do acctual storing of values
|
||||
d->timestamp = timestamp;
|
||||
}
|
24
telldus-core/service/Sensor.h
Normal file
24
telldus-core/service/Sensor.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef SENSOR_H
|
||||
#define SENSOR_H
|
||||
|
||||
#include "Mutex.h"
|
||||
#include <string>
|
||||
|
||||
class Sensor : public TelldusCore::Mutex
|
||||
{
|
||||
public:
|
||||
Sensor(const std::wstring &protocol, const std::wstring &model, int id);
|
||||
~Sensor();
|
||||
|
||||
std::wstring protocol() const;
|
||||
std::wstring model() const;
|
||||
int id() const;
|
||||
|
||||
void setValue(const std::string &name, const std::string &value, time_t timestamp);
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d;
|
||||
};
|
||||
|
||||
#endif // SENSOR_H
|
Loading…
Add table
Add a link
Reference in a new issue