]> pilppa.org Git - lib1wire.git/blob - src/W1Device.hh
e5de6d971cd0f0b9e233ea883e061fde3a56202f
[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
19 #ifndef W1_SCAN_ROOTDIR
20 #define W1_SCAN_ROOTDIR         "/sys/bus/w1/devices"
21 #endif
22
23 #ifndef W1_SLAVE_FILE
24 #define W1_SLAVE_FILE           "w1_slave";
25 #endif
26
27 namespace w1 {
28         class W1Device {
29                 public:
30                         W1Device(int family_code_param,
31                                 std::string device_id_param,
32                                 dirent *direntry_param);
33                         virtual ~W1Device();
34                         int get_w1_family_code();
35                         std::string get_id();
36                         std::string get_name();
37                         void set_name(std::string name_param);
38                         virtual std::string get_unit() = 0;
39                         virtual std::string get_device_type() = 0;
40                         plp::Data *get_and_collect_data();
41                         virtual void save_data();
42                         virtual void printout();
43                 protected:
44                         virtual std::vector<double> *get_raw_data() = 0;
45                         virtual unsigned int get_data_decimal_precision() = 0;
46                         void collect_data(plp::Data *data);
47                         std::string to_string(double val, int digit_count);
48                         //Data *get_formatted_data(Data *data);
49                         virtual bool is_supported_w1_family_code(int family_code) = 0;
50                         int family_code;
51                         std::string id;
52                         std::string name;
53                         std::string dir_path;
54                         std::string slave_file;
55                         std::list<plp::Data *> memory_cache;
56         };
57 }
58
59 #endif /* W1DEVICE_HH_ */