also outside of lib1wire library eventually.
Signed-off-by: Mika Laitio <lamikr@pilppa.org>
--- /dev/null
+/*
+ * GenericDevice.hh
+ *
+ * Created on: Feb 28, 2011
+ * Author: lamikr
+ */
+
+#ifndef DEVICETYPEGENERIC_HH_
+#define DEVICETYPEGENERIC_HH_
+
+#include <string>
+
+namespace plp {
+ class DeviceTypeGeneric {
+ public:
+ virtual std::string get_id() = 0;
+ virtual std::string get_name() = 0;
+ virtual void set_name(std::string name_param) = 0;
+ virtual std::string get_device_type() = 0;
+ virtual void printout() = 0;
+ };
+}
+
+#endif /* DEVICETYPEGENERIC_HH_ */
--- /dev/null
+/*
+ * DeviceTypeSensor.hh
+ *
+ * Created on: Feb 28, 2011
+ * Author: lamikr
+ */
+
+#ifndef DEVICETYPESENSOR_HH_
+#define DEVICETYPESENSOR_HH_
+
+#include <string>
+
+#include "DeviceTypeGeneric.hh"
+
+namespace plp {
+ class DeviceTypeSensor : public DeviceTypeGeneric {
+ public:
+ virtual std::string get_unit() = 0;
+ virtual plp::Data *get_data() = 0;
+ virtual void save_data() = 0;
+ };
+}
+
+#endif /* DEVICETYPESENSOR_HH_ */
lib_LTLIBRARIES = lib1wire.la
lib1wire_la_SOURCES = \
+ Data.cc Data.hh \
+ Date.cc Date.hh \
+ DeviceConfig.cc DeviceConfig.hh \
+ DeviceData.cc DeviceData.hh \
+ DeviceTypeGeneric.hh \
+ DeviceTypeSensor.hh \
Factory.cc Factory.hh \
- W1Device.cc W1Device.hh \
Store.cc Store.hh \
StoreDay.cc StoreDay.hh \
StoreCache.cc StoreCache.hh \
- W1TemperatureSensor.cc W1TemperatureSensor.hh \
W1CounterDevice.cc W1CounterDevice.hh \
+ W1Device.cc W1Device.hh \
+ W1TemperatureSensor.cc W1TemperatureSensor.hh \
W1Util.cc W1Util.hh \
- DeviceData.cc DeviceData.hh \
- DeviceConfig.cc DeviceConfig.hh \
- Data.cc Data.hh \
- Date.cc Date.hh \
W1Configure.hh
lib1wire_la_LDFLAGS = $(SRC_LIBS) $(all_libraries) -version-info 1:0:0 -no-undefined
AM_CPPFLAGS = $(SRC_CFLAGS)
Date.hh \
DeviceConfig.hh \
DeviceData.hh \
+ DeviceTypeGeneric.hh \
+ DeviceTypeSensor.hh \
Factory.hh \
- W1CounterDevice.hh \
- W1Device.hh \
Store.hh \
StoreDay.hh \
StoreCache.hh \
+ W1CounterDevice.hh \
+ W1Device.hh \
W1TemperatureSensor.hh \
W1Util.hh
\ No newline at end of file
Data *data;
string text;
- data = get_and_collect_data();
+ data = get_data();
if (data != NULL) {
text = data->to_string();
cout << text << endl;
return ret_val;
}
-
-Data *W1Device::get_and_collect_data() {
+Data *W1Device::get_data() {
Data *ret_val;
vector<double> *vect;
#include <stdbool.h>
#include "Data.hh"
+#include "DeviceTypeSensor.hh"
#ifndef W1_SCAN_ROOTDIR
#define W1_SCAN_ROOTDIR "/sys/bus/w1/devices"
#endif
namespace w1 {
- class W1Device {
+ class W1Device : public plp::DeviceTypeSensor {
public:
W1Device(int family_code_param,
std::string device_id_param,
std::string get_id();
std::string get_name();
void set_name(std::string name_param);
- virtual std::string get_unit() = 0;
- virtual std::string get_device_type() = 0;
- plp::Data *get_and_collect_data();
- virtual void save_data();
- virtual void printout();
+ void printout();
+ plp::Data *get_data();
+ void save_data();
protected:
virtual std::vector<double> *get_raw_data() = 0;
virtual unsigned int get_data_decimal_precision() = 0;