/* * W1Device.hh * * Created on: Oct 20, 2010 * Author: lamikr */ #ifndef W1DEVICE_HH_ #define W1DEVICE_HH_ #include #include #include #include #include #include #include #include #include #ifndef W1_SCAN_ROOTDIR #define W1_SCAN_ROOTDIR "/sys/bus/w1/devices" #endif #ifndef W1_SLAVE_FILE #define W1_SLAVE_FILE "w1_slave"; #endif namespace w1 { class W1Device : public plp::SensorDevice { public: W1Device(std::string device_id_param, std::string device_type_param, dirent *direntry_param); ~W1Device(); std::string get_name(); void set_name(std::string name_param); void printout(); plp::Data *get_data(); const plp::DataReader *get_device_data(); protected: std::string dir_path; std::string slave_file; std::list memory_cache; plp::DataReader *reader; void save_and_clean_cache(); virtual std::vector *get_raw_data() = 0; virtual unsigned int get_data_decimal_precision() { return 1; } void cache(plp::Data *new_data); std::string to_string(double val, int digit_count); pthread_mutex_t plock; }; } #endif /* W1DEVICE_HH_ */