4 * Created on: Oct 20, 2010
14 #include "W1Device.hh"
19 W1Device::W1Device(int family_code_param,
20 string device_id_param,
21 dirent *direntry_param) {
26 rootdir = W1_SCAN_ROOTDIR;
27 temp_str = W1_SLAVE_FILE;
28 dir_path = rootdir + "/" + direntry_param->d_name;
29 slave_file = dir_path + "/" + temp_str;
30 log_debug("w1 data file: %s\n", slave_file.c_str());
31 family_code = family_code_param;
33 name = device_id_param;
36 W1Device::~W1Device() {
39 int W1Device::get_family_code() {
43 string W1Device::get_id() {
47 string W1Device::get_name() {
51 void W1Device::set_name(string name_param) {
55 string W1Device::get_time() {
62 ltime = localtime(&wtime);
63 strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", ltime);
68 void W1Device::printout() {
71 text = get_formatted_data();
75 string W1Device::get_formatted_data() {
80 ret_val = get_formatted_data(val);
84 string W1Device::get_formatted_data(string raw_data) {
87 ret_val = get_time() + "|" + raw_data + " " + get_unit();
88 add_to_memory_cache(ret_val);
92 void W1Device::add_to_memory_cache(std::string formatted_data) {
93 // TODO: add mutex for memory_cache
94 memory_cache.push_back(formatted_data);
97 void W1Device::store() {
98 W1Store::store(id, &memory_cache);