4 * Created on: Oct 20, 2010
13 #include "W1Device.hh"
18 W1Device::W1Device(dirent *direntry,
19 int family_code_param,
25 rootdir = W1_SCAN_ROOTDIR;
26 temp_str = W1_SLAVE_FILE;
27 dir_path = rootdir + "/" + direntry->d_name;
28 slave_file = dir_path + "/" + temp_str;
29 family_code = family_code_param;
34 W1Device::~W1Device() {
37 int W1Device::get_family_code() {
41 string W1Device::get_id() {
45 string W1Device::get_name() {
49 void W1Device::set_name(string name_param) {
53 string W1Device::get_time() {
60 ltime = localtime(&wtime);
61 strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", ltime);
66 void W1Device::printout() {
69 text = get_formatted_value();
73 string W1Device::get_formatted_value() {
77 val = get_raw_value();
78 ret_val = get_formatted_value(val);
82 string W1Device::get_formatted_value(string value) {
85 ret_val = get_time() + "|" + get_devicetype_name() + "|" + id + "|" + value + " " + get_unit();
86 add_to_memory_cache(ret_val);
90 void W1Device::add_to_memory_cache(std::string formatted_data) {
91 // TODO: add mutex for memory_cache
92 memory_cache.push_back(formatted_data);
95 void W1Device::store() {
96 W1Store::store(id, &memory_cache);