From a825b61a8faebeca8b8550c57ac197f67bc110f1 Mon Sep 17 00:00:00 2001 From: Mika Laitio Date: Thu, 10 Mar 2011 19:58:19 +0200 Subject: [PATCH] fixes for w1 data read Signed-off-by: Mika Laitio --- src/Device.cc | 40 ++++++++++++++++++++++++++++++++++------ src/Device.hh | 34 +++++++++++++++++++++++----------- src/DeviceData.cc | 37 +++++-------------------------------- src/DeviceData.hh | 30 ++++++++---------------------- src/Makefile.am | 4 ++-- src/SensorDevice.hh | 6 +++++- 6 files changed, 77 insertions(+), 74 deletions(-) diff --git a/src/Device.cc b/src/Device.cc index 8923ff8..96189bc 100644 --- a/src/Device.cc +++ b/src/Device.cc @@ -1,19 +1,47 @@ /* * Device.cc * - * Created on: Mar 5, 2011 + * Created on: Mar 4, 2011 * Author: lamikr */ -#include - #include "Device.hh" -#include "DeviceConfig.hh" using namespace std; using namespace plp; -Device::Device(string id_param, string type_param) : plp::DeviceData(id_param, type_param) { +Device::Device(string id_param, string type_param) { + id = id_param; + type = type_param; + lifecycle_status = LIFECYCLE_STATUS__UNAVAILABLE; +} + +Device::Device(std::string id_param, std::string type_param, std::string name_param, plp::EnumDeviceLifeCycleStatus status_param) { + id = id_param; + type = type_param; + name = name_param; + lifecycle_status = status_param; +} + +Device::~Device() { + +} + +string Device::get_id() { + return id; +} + +string Device::get_name() { + return name; +} + +void Device::set_name(string name_param) { + name = name_param; +} + +EnumDeviceLifeCycleStatus Device::get_lifecycle_state() { + return lifecycle_status; } -Device::Device(string id_param, string type_param, string name_param, EnumDeviceLifeCycleStatus status_param) : plp::DeviceData(id_param, type_param, name_param, status_param) { +string Device::get_type() { + return type; } diff --git a/src/Device.hh b/src/Device.hh index a0984ff..c165b1c 100644 --- a/src/Device.hh +++ b/src/Device.hh @@ -1,25 +1,37 @@ /* - * GenericDevice.hh + * Device.hh * - * Created on: Feb 28, 2011 + * Created on: Mar 4, 2011 * Author: lamikr */ -#ifndef DEVICE_HH_ -#define DEVICE_HH_ +#ifndef DEVICEINFO_HH_ +#define DEVICEINFO_HH_ #include -#include "DeviceData.hh" -#include "DataReader.hh" +using namespace std; namespace plp { - class Device : public DeviceData { + enum EnumDeviceLifeCycleStatus {LIFECYCLE_STATUS__UNAVAILABLE, LIFECYCLE_STATUS__AVAILABLE}; + + class Device { public: - Device(std::string id_param, std::string type_param); - Device(std::string id_param, std::string type_param, std::string name_param, plp::EnumDeviceLifeCycleStatus status_param); - virtual plp::DataReader *get_device_data() = 0; + Device(string id_param, string type_param); + Device(string id_param, string type_param, string name_param, EnumDeviceLifeCycleStatus status_param); + ~Device(); + std::string get_id(); + std::string get_name(); + std::string get_type(); + plp::EnumDeviceLifeCycleStatus get_lifecycle_state(); + void set_name(std::string name_param); + virtual void printout() = 0; + protected: + std::string id; + std::string name; + std::string type; + plp::EnumDeviceLifeCycleStatus lifecycle_status; }; } -#endif /* DEVICE_HH_ */ +#endif /* DEVICEINFO_HH_ */ diff --git a/src/DeviceData.cc b/src/DeviceData.cc index 60edf5e..1621d05 100644 --- a/src/DeviceData.cc +++ b/src/DeviceData.cc @@ -1,50 +1,23 @@ /* * DeviceData.cc * - * Created on: Mar 4, 2011 + * Created on: Mar 10, 2011 * Author: lamikr */ -#include + #include "DeviceData.hh" using namespace std; using namespace plp; -DeviceData::DeviceData(string id_param, string type_param) { - id = id_param; - type = type_param; - lifecycle_status = LIFECYCLE_STATUS__UNAVAILABLE; -} - -DeviceData::DeviceData(std::string id_param, std::string type_param, std::string name_param, plp::EnumDeviceLifeCycleStatus status_param) { - id = id_param; - type = type_param; - name = name_param; - lifecycle_status = status_param; +DeviceData::DeviceData(string id_param, string type_param) : Device(id_param, type_param) { } -DeviceData::~DeviceData() { +DeviceData::DeviceData(string id_param, string type_param, string name_param, EnumDeviceLifeCycleStatus status_param) : Device(id_param, type_param, name_param, status_param) { } -string DeviceData::get_id() { - return id; -} - -string DeviceData::get_name() { - return name; -} - -void DeviceData::set_name(string name_param) { - name = name_param; -} - -EnumDeviceLifeCycleStatus DeviceData::get_lifecycle_state() { - return lifecycle_status; -} - -string DeviceData::get_type() { - return type; +DeviceData::~DeviceData() { } void DeviceData::printout() { diff --git a/src/DeviceData.hh b/src/DeviceData.hh index ce0f89a..5b11047 100644 --- a/src/DeviceData.hh +++ b/src/DeviceData.hh @@ -1,37 +1,23 @@ /* * DeviceData.hh * - * Created on: Mar 4, 2011 + * Created on: Mar 10, 2011 * Author: lamikr */ -#ifndef DEVICEINFO_HH_ -#define DEVICEINFO_HH_ +#ifndef DEVICEDATA_HH_ +#define DEVICEDATA_HH_ -#include - -using namespace std; +#include "Device.hh" namespace plp { - enum EnumDeviceLifeCycleStatus {LIFECYCLE_STATUS__UNAVAILABLE, LIFECYCLE_STATUS__AVAILABLE}; - - class DeviceData { + class DeviceData : public Device { public: - DeviceData(string id_param, string type_param); - DeviceData(string id_param, string type_param, string name_param, EnumDeviceLifeCycleStatus status_param); + DeviceData(std::string id_param, std::string type_param); + DeviceData(std::string id_param, std::string type_param, std::string name_param, plp::EnumDeviceLifeCycleStatus status_param); ~DeviceData(); - std::string get_id(); - std::string get_name(); - std::string get_type(); - plp::EnumDeviceLifeCycleStatus get_lifecycle_state(); - void set_name(std::string name_param); void printout(); - protected: - std::string id; - std::string name; - std::string type; - plp::EnumDeviceLifeCycleStatus lifecycle_status; }; } -#endif /* DEVICEINFO_HH_ */ +#endif /* DEVICEDATA_HH_ */ diff --git a/src/Makefile.am b/src/Makefile.am index 183b03b..b815100 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,8 +5,8 @@ libplp_la_SOURCES = \ DataReader.hh DataReader.cc \ Date.hh Date.cc \ Device.hh Device.cc \ - DeviceConfig.hh DeviceConfig.cc \ DeviceData.hh DeviceData.cc \ + DeviceConfig.hh DeviceConfig.cc \ DeviceTypes.hh \ FileUtil.cc FileUtil.hh \ SensorDevice.hh \ @@ -30,8 +30,8 @@ libplpinclude_HEADERS = \ DataReader.hh \ Date.hh \ Device.hh \ - DeviceConfig.hh \ DeviceData.hh \ + DeviceConfig.hh \ DeviceTypes.hh \ FileUtil.hh \ SensorDevice.hh \ diff --git a/src/SensorDevice.hh b/src/SensorDevice.hh index 80c02df..1eea031 100644 --- a/src/SensorDevice.hh +++ b/src/SensorDevice.hh @@ -10,13 +10,17 @@ #include +#include "DataReader.hh" #include "Device.hh" +using namespace plp; + namespace plp { class SensorDevice : public Device { public: SensorDevice(std::string id_param, std::string type_param) : Device(id_param, type_param) {} - virtual std::string get_unit() = 0; + virtual DataReader *get_device_data() = 0; + virtual string get_unit() = 0; virtual plp::Data *get_data() = 0; }; } -- 2.41.1