Rev 3375 Rev 3376
Line 11... Line 11...
11   11  
12 #### Script Arguments ############################################### 12 #### Script Arguments ###############################################
13   13  
14 if len(sys.argv) != 2: 14 if len(sys.argv) != 2:
15 sys.stderr.write("Invalid number of arguments.\n") 15 sys.stderr.write("Invalid number of arguments.\n")
16 sys.stderr.write("Usage: %s PORT ADDRESS\n" % (sys.argv[0], )) 16 sys.stderr.write("Usage: %s #I2CPORT\n" % (sys.argv[0], ))
17 sys.exit(1) 17 sys.exit(1)
18   18  
19 port = eval(sys.argv[1]) 19 port = eval(sys.argv[1])
20   20  
21   21  
22 #### Sensor Configuration ########################################### 22 #### Sensor Configuration ###########################################
23   23  
24 cfg = config.Config( 24 cfg = config.Config(
-   25 port = port,
25 bus = [ 26 bus = [
-   27 {
-   28 "type": "i2chub",
-   29 "address": 0x72,
-   30
-   31 "children": [
-   32 {
-   33 "type": "i2chub",
-   34 "address": 0x70,
-   35 "channel": 3,
-   36 "children": [
-   37 {"name": "altimet1", "type": "altimet01" , "channel": 0, },
-   38 {"name": "altimet2", "type": "altimet01" , "channel": 3, },
-   39 {"name": "altimet3", "type": "altimet01" , "channel": 4, },
-   40 {"name": "altimet4", "type": "altimet01" , "channel": 5, },
-   41 {"name": "altimet5", "type": "altimet01" , "channel": 6, },
-   42 {"name": "altimet6", "type": "altimet01" , "channel": 7, },
-   43 ],
-   44 },
-   45 {"name": "altimet8", "type": "altimet01" , "channel": 6, },
-   46 ],
-   47 },
-   48  
26 # { 49 # {
27 # "type": "i2chub", 50 # "type": "i2chub",
28 # "address": 0x70, 51 # "address": 0x72,
29 # -  
30 # "children": [ 52 # "children": [
31 # { -  
32 # "type": "i2chub", 53 # {"name": "altimet", "type": "altimet01" , "channel": 6, },
33 # "address": 0x70, -  
34 # "channel": 1, -  
35 # -  
36 # }, -  
37 # ], 54 # ],
38 # }, 55 # },
39   56  
40 { -  
41 "name": "altimet", -  
42 "type": "altimet01", -  
43 }, -  
44   -  
45   57  
46 ], 58 ],
47 ) 59 )
48 cfg.initialize() 60 cfg.initialize()
49   61  
-   62 gauge1 = cfg.get_device("altimet1")
-   63 gauge2 = cfg.get_device("altimet2")
50 gauge = cfg.get_device("altimet") 64 gauge3 = cfg.get_device("altimet3")
-   65 gauge4 = cfg.get_device("altimet4")
-   66 gauge5 = cfg.get_device("altimet5")
-   67 gauge6 = cfg.get_device("altimet6")
51   68  
-   69 gauge8 = cfg.get_device("altimet8")
-   70 time.sleep(0.5)
52   71  
53 #### Data Logging ################################################### 72 #### Data Logging ###################################################
54   73  
-   74  
55 try: 75 try:
56 with open("temperature.log", "a") as f: 76 with open("temperature.log", "a") as f:
57 while True: 77 while True:
58 sys.stdout.write("Start measurement now? [ENTER]") 78 sys.stdout.write("Start measurement now? [ENTER]")
59 sys.stdin.readline() 79 sys.stdin.readline()
-   80 gauge1.route()
60 (t, p) = gauge.get_tp() 81 (t1, p1) = gauge1.get_tp()
-   82 gauge2.route()
-   83 (t2, p2) = gauge2.get_tp()
-   84 gauge3.route()
-   85 (t3, p3) = gauge3.get_tp()
-   86 gauge4.route()
-   87 (t4, p4) = gauge4.get_tp()
-   88 gauge5.route()
-   89 (t5, p5) = gauge5.get_tp()
-   90 gauge6.route()
-   91 (t6, p6) = gauge6.get_tp()
-   92 # gauge7.route()
-   93 # (t7, p7) = gauge7.get_tp()
-   94 gauge8.route()
-   95 (t8, p8) = gauge8.get_tp()
-   96  
61 sys.stdout.write(" Temperature: %.2f Pressure: %d Note: " % (t, p, )) 97 sys.stdout.write(" Temperature: %.2f %.2f %.2f %.2f %.2f %.2f %.2f Pressure: %d %d %d %d %d %d %d Note: " % (t1, t2, t3, t4, t5, t6, t8, p1, p2, p3, p4, p5, p6, p8, ))
62 note = sys.stdin.readline() 98 note = sys.stdin.readline()
63 f.write("%d\t%s\t%.2f\t%d\t%s\n" % (time.time(), datetime.datetime.now().isoformat(), t, p, note, )) 99 f.write("%d\t%s\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%s\n" % (time.time(), datetime.datetime.now().isoformat(),t1, t2, t3, t4, t5, t6, t8, p1, p2, p3, p4, p5, p6, p8, note, ))
64 sys.stdout.flush() 100 sys.stdout.flush()
65 time.sleep(0.5) 101 time.sleep(0.5)
66 except KeyboardInterrupt: 102 except KeyboardInterrupt:
67 sys.exit(0) 103 sys.exit(0)
68   104