Rev 3374 Rev 3375
Line 9... Line 9...
9 from pymlab import config 9 from pymlab import config
10   10  
11   11  
12 #### Script Arguments ############################################### 12 #### Script Arguments ###############################################
13   13  
14 if len(sys.argv) != 3: 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 PORT ADDRESS\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 address = eval(sys.argv[2]) -  
21   20  
22   21  
23 #### Sensor Configuration ########################################### 22 #### Sensor Configuration ###########################################
24   23  
25 cfg = config.Config( 24 cfg = config.Config(
26 port = 1, -  
27 -  
28 bus = [ 25 bus = [
29 { 26 # {
30 "type": "i2chub", 27 # "type": "i2chub",
31 "address": 0x70, 28 # "address": 0x70,
32 29 #
33 "children": [ 30 # "children": [
34 { 31 # {
35 "type": "i2chub", 32 # "type": "i2chub",
36 "address": 0x70, 33 # "address": 0x70,
37 "channel": 1, 34 # "channel": 1,
38 35 #
39 }, 36 # },
40 ], 37 # ],
41 }, 38 # },
-   39  
-   40 {
-   41 "name": "altimet",
-   42 "type": "altimet01",
-   43 },
-   44  
-   45  
42 ], 46 ],
43 ) 47 )
44 cfg.initialize() 48 cfg.initialize()
45   49  
46 gauge = cfg.get_device("altimet") 50 gauge = cfg.get_device("altimet")
Line 49... Line 53...
49 #### Data Logging ################################################### 53 #### Data Logging ###################################################
50   54  
51 try: 55 try:
52 with open("temperature.log", "a") as f: 56 with open("temperature.log", "a") as f:
53 while True: 57 while True:
-   58 sys.stdout.write("Start measurement now? [ENTER]")
-   59 sys.stdin.readline()
54 (t, p) = gauge.get_tp() 60 (t, p) = gauge.get_tp()
55 #sys.stdout.write(" Temperature: " + str(t) + " Preassure: " + str(p) + "\r\n") 61 sys.stdout.write(" Temperature: %.2f Pressure: %d Note: " % (t, p, ))
56 sys.stdout.write(" Temperature: %.2f Pressure: %d\n" % (t, p, )) 62 note = sys.stdin.readline()
57 f.write("%d\t%s\t%.2f\t%d\n" % (time.time(), datetime.datetime.now().isoformat(), t, p, )) 63 f.write("%d\t%s\t%.2f\t%d\t%s\n" % (time.time(), datetime.datetime.now().isoformat(), t, p, note, ))
58 sys.stdout.flush() 64 sys.stdout.flush()
59 time.sleep(0.5) 65 time.sleep(0.5)
60 except KeyboardInterrupt: 66 except KeyboardInterrupt:
61 sys.exit(0) 67 sys.exit(0)
62   68