]> pilppa.org Git - lib1wire.git/blob - src/W1Device.hh
d1371e9e5214a598bd267872bfef9a076789c03f
[lib1wire.git] / src / W1Device.hh
1 /*
2  * W1Device.hh
3  *
4  *  Created on: Oct 20, 2010
5  *      Author: lamikr
6  */
7
8 #ifndef W1DEVICE_HH_
9 #define W1DEVICE_HH_
10
11 #include <string>
12 #include <list>
13
14 #include <dirent.h>
15 #include <stdbool.h>
16
17 #include "Data.hh"
18 #include "DeviceTypeSensor.hh"
19
20 #ifndef W1_SCAN_ROOTDIR
21 #define W1_SCAN_ROOTDIR         "/sys/bus/w1/devices"
22 #endif
23
24 #ifndef W1_SLAVE_FILE
25 #define W1_SLAVE_FILE           "w1_slave";
26 #endif
27
28 namespace w1 {
29         class W1Device : public plp::DeviceTypeSensor {
30                 public:
31                         W1Device(int family_code_param,
32                                 std::string device_id_param,
33                                 dirent *direntry_param);
34                         virtual ~W1Device();
35                         int get_w1_family_code();
36                         std::string get_id();
37                         std::string get_name();
38                         void set_name(std::string name_param);
39                         void printout();
40                         plp::Data *get_data();
41                         void save_data();
42                 protected:
43                         virtual std::vector<double> *get_raw_data() = 0;
44                         virtual unsigned int get_data_decimal_precision() = 0;
45                         void collect_data(plp::Data *data);
46                         std::string to_string(double val, int digit_count);
47                         //Data *get_formatted_data(Data *data);
48                         virtual bool is_supported_w1_family_code(int family_code) = 0;
49                         int family_code;
50                         std::string id;
51                         std::string name;
52                         std::string dir_path;
53                         std::string slave_file;
54                         std::list<plp::Data *> memory_cache;
55         };
56 }
57
58 #endif /* W1DEVICE_HH_ */