Rev 553 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 553 | Rev 554 | ||
---|---|---|---|
Line 20... | Line 20... | ||
20 | def usage(): |
20 | def usage(): |
21 | print |
21 | print |
22 | print "VibrationTest.py COMPORT MOTORS SPEEDS CHANNELS [-m MINSPEED] [-s NBSAMPLES] [-n NAME] [-d FILENAME] [-v]" |
22 | print "VibrationTest.py COMPORT MOTORS SPEEDS CHANNELS [-m MINSPEED] [-s NBSAMPLES] [-n NAME] [-d FILENAME] [-v]" |
23 | print " COMPORT Serial port to use. e.g. COM4" |
23 | print " COMPORT Serial port to use. e.g. COM4" |
24 | print " MOTORS Motors to activate during test. Multiple motors can be used at the same time. e.g. 1,2,3,4" |
24 | print " MOTORS Motors to activate during test. Multiple motors can be used at the same time. e.g. 1,2,3,4" |
25 | print " SPEEDS Indicates at what speeds the motors need to be tested. e.g. 50,80,110,140,170" |
25 | print " SPEEDS Indicates at what speeds the motors need to be tested. " |
- | 26 | print " Format 1: e.g. 50,110,140 Tests at speeds 50, 110 and 140" |
|
- | 27 | print " Format 2: e.g. 100-200:50 Tests at speeds 100, 150 and 200" |
|
26 | print " CHANNELS Channels to monitor. e.g. 5,6,7" |
28 | print " CHANNELS Channels to monitor. e.g. 5,6,7" |
27 | i = 0 |
- | |
28 | for channelName in CHANNEL_NAMES: |
29 | for i,channelName in enumerate(CHANNEL_NAMES): |
29 | print " Channel %d = %s" % (i, channelName) |
30 | print " Channel %d = %s" % (i, channelName) |
30 | i += 1 |
- | |
31 | print " -m MINSPEED Minimum speed of the motor(s)" |
31 | print " -m MINSPEED Minimum speed of the motor(s)" |
32 | print " -s NBSAMPLES Number of samples" |
32 | print " -s NBSAMPLES Number of samples" |
33 | print " -n NAME Name of the test" |
33 | print " -n NAME Name of the test" |
34 | print " -d FILENAME File to which the measured values will be logged in" |
34 | print " -d FILENAME File to which the measured values will be logged in" |
35 | print " -v Verbose" |
35 | print " -v Verbose" |
36 | print |
36 | print |
37 | 37 | ||
- | 38 | def exit_usage(): |
|
- | 39 | usage() |
|
- | 40 | sys.exit(2) |
|
Line 38... | Line 41... | ||
38 | 41 | ||
Line 39... | Line 42... | ||
39 | if __name__ == '__main__': |
42 | if __name__ == '__main__': |
40 | 43 | ||
41 | #print sys.argv |
44 | #print sys.argv |
42 | if len(sys.argv)<5: |
- | |
Line 43... | Line 45... | ||
43 | usage() |
45 | if len(sys.argv)<5: |
44 | sys.exit(2) |
46 | exit_usage() |
45 | - | ||
46 | parComPort = sys.argv[1] |
47 | |
- | 48 | parComPort = sys.argv[1] |
|
- | 49 | parMotors = sys.argv[2].split(',') |
|
- | 50 | parChannels = sys.argv[4].split(',') |
|
- | 51 | ||
- | 52 | par = sys.argv[3] |
|
- | 53 | if par.count("-") == 1: |
|
- | 54 | # assume from-to:step format |
|
- | 55 | par = par.split("-") |
|
- | 56 | if len(par) != 2: |
|
- | 57 | exit_usage() |
|
- | 58 | ||
- | 59 | par[1] = par[1].split(":") |
|
- | 60 | if len(par[1]) != 2: |
|
- | 61 | exit_usage() |
|
- | 62 | ||
- | 63 | parSpeeds = range(int(par[0]),int(par[1][0])+int(par[1][1]),int(par[1][1])) |
|
Line 47... | Line 64... | ||
47 | parMotors = sys.argv[2].split(',') |
64 | |
48 | parSpeeds = sys.argv[3].split(',') |
65 | else: |
49 | parChannels = sys.argv[4].split(',') |
66 | parSpeeds = par.split(',') |
50 | 67 |