]> pilppa.org Git - lib1wire.git/blob - src_test/test_w1.cc
formating fixes for celcius values
[lib1wire.git] / src_test / test_w1.cc
1 /*
2  * test_w1.cc
3  *
4  *  Created on: Oct 20, 2010
5  *      Author: lamikr
6  */
7 #include <list>
8 #include <string>
9 #include <iostream>
10
11 #include <unistd.h>
12
13 #include "W1Scanner.hh"
14
15 using namespace w1;
16 using namespace std;
17
18 int main(int argc, char** argv)
19 {
20         W1Scanner                       *scanner;
21         list<W1Device *>        device_list;
22         int                                     round;
23         int                                     interval_seconds;
24         int                                     store_interval;
25
26         interval_seconds        = 60;
27         store_interval          = 10;
28         scanner                         = new W1Scanner();
29         device_list                     = scanner->get_device_list();
30         round                           = 0;
31         while(1) {
32                 round++;
33                 for(list<W1Device *>::iterator list_iter = device_list.begin(); list_iter != device_list.end(); list_iter++)
34                 {
35                         W1Device *device = (W1Device *)*list_iter;
36 /*
37                         string name     = device->get_name();
38                         string value    = device->get_value();
39                         string unit             = device->get_unit();
40                         cout << name << ": " << value << " " << unit << endl;
41 */
42                         device->printout();
43                         sleep(1);
44                         if (round >= store_interval) {
45                                 device->store();
46                         }
47                 }
48                 sleep(interval_seconds);
49                 if (round >= store_interval) {
50                         round = 0;
51                 }
52         }
53         return 0;
54 }