]> pilppa.org Git - lib1wire.git/blob - src/W1Device.hh
Api cleanups for device querying
[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 "SensorDevice.hh"
19 #include "Device.hh"
20
21 #ifndef W1_SCAN_ROOTDIR
22 #define W1_SCAN_ROOTDIR         "/sys/bus/w1/devices"
23 #endif
24
25 #ifndef W1_SLAVE_FILE
26 #define W1_SLAVE_FILE           "w1_slave";
27 #endif
28
29 namespace w1 {
30         class W1Device : public plp::SensorDevice {
31                 public:
32                         W1Device(std::string device_type_param,
33                                 std::string device_id_param,
34                                 dirent *direntry_param);
35                         virtual ~W1Device();
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                         plp::DataReader *get_device_data();
42                         std::string get_device_type();
43                         plp::EnumDeviceLifeCycleStatus get_lifecycle_state();
44                 protected:
45                         void save_and_clean_cache();
46                         virtual std::vector<double> *get_raw_data() = 0;
47                         virtual unsigned int get_data_decimal_precision() = 0;
48                         void cache(plp::Data *data);
49                         std::string to_string(double val, int digit_count);
50                         //Data *get_formatted_data(Data *data);
51                         std::string id;
52                         std::string type;
53                         std::string name;
54                         std::string dir_path;
55                         std::string slave_file;
56                         std::list<plp::Data *> memory_cache;
57                         plp::EnumDeviceLifeCycleStatus lifecycle_status;
58         };
59 }
60
61 #endif /* W1DEVICE_HH_ */