|
9 | 9 | from matplotlib import pyplot as plt |
10 | 10 | import numpy as np |
11 | 11 |
|
| 12 | +def log_and_print_to_console(message_string): |
| 13 | + print(message_string) |
| 14 | + |
| 15 | +def receive_user_input_and_log(): |
| 16 | + inputText = input() |
| 17 | + return inputText |
| 18 | + |
12 | 19 | slow_sampling_string = "SLOWLOG" |
13 | 20 | medium_sampling_string = "MEDIUMLOG" |
14 | 21 | fast_sampling_string = "FASTLOG" |
| 22 | +slow_sampling_mode = 3 |
| 23 | +medium_sampling_mode = 2 |
| 24 | +fast_sampling_mode = 1 |
| 25 | + |
15 | 26 | # the number of samples |
16 | 27 | # use for checking wheather the plot is fast or slow log sampling |
17 | 28 | num_of_data_fastLog = 525 |
|
21 | 32 | filename_grease_log = "digitizer_log_sampling_grease.log" |
22 | 33 | filename_no_grease_log = "digitizer_log_sampling_noGrease.log" |
23 | 34 |
|
| 35 | +log_and_print_to_console('\nEnter the option # for sampling mode:\n1. FASTLOG.\n2. MEDIUMLOG\n3. SLOWLOG.\n') |
| 36 | +sampling_mode_input = float(receive_user_input_and_log()) |
| 37 | + |
24 | 38 | ### start of main program |
25 | 39 | try: |
26 | 40 | # open grease data file in current directory |
|
58 | 72 | else: |
59 | 73 | num_of_data = num_of_data_noGrease |
60 | 74 |
|
61 | | - if num_of_data == num_of_data_fastLog: |
| 75 | + if sampling_mode_input == fast_sampling_mode: |
62 | 76 | sampling_mode_string = fast_sampling_string |
63 | | - elif num_of_data == num_of_data_mediumLog: |
| 77 | + elif sampling_mode_input == medium_sampling_mode: |
64 | 78 | sampling_mode_string = medium_sampling_string |
65 | | - elif num_of_data == num_of_data_slowLog: |
| 79 | + elif sampling_mode_input == slow_sampling_mode: |
66 | 80 | sampling_mode_string = slow_sampling_string |
67 | 81 |
|
68 | 82 | # plot graph |
|
79 | 93 | time_value.append(Time_us/1000000) |
80 | 94 | if sampling_mode_string == slow_sampling_string: |
81 | 95 | # log time scale |
82 | | - if i > 0 and i <=99: |
83 | | - Time_us = Time_us + 1000 |
84 | | - elif i > 99 and i <= 189: |
85 | | - Time_us = Time_us + 10000 |
86 | | - elif i > 189 and i <= 279: |
87 | | - Time_us = Time_us + 100000 |
88 | | - elif i > 279 and i <= 369: |
89 | | - Time_us = Time_us + 1000000 |
90 | | - elif i > 369 and i <= 459: |
91 | | - Time_us = Time_us + 10000000 |
| 96 | + if i > 0 and i <=49: |
| 97 | + Time_us = Time_us + 2 |
| 98 | + elif i > 49 and i <= 139: |
| 99 | + Time_us = Time_us + 10 |
| 100 | + elif i > 139 and i <= 229: |
| 101 | + Time_us = Time_us + 100 |
| 102 | + elif i > 229 and i <= 319: |
| 103 | + Time_us = Time_us + 1000 |
| 104 | + elif i > 319 and i <= 364: |
| 105 | + Time_us = Time_us + 20000 |
| 106 | + elif i > 364 and i <= 409: |
| 107 | + Time_us = Time_us + 200000 |
| 108 | + elif i > 409 and i <= 454: |
| 109 | + Time_us = Time_us + 2000000 |
| 110 | + elif i > 454 and i <= 500: |
| 111 | + Time_us = Time_us + 20000000 |
92 | 112 | elif sampling_mode_string == medium_sampling_string: |
93 | 113 | if i >= 0 and i <=49: |
94 | 114 | Time_us = Time_us + 2 |
|
0 commit comments