bf
This commit is contained in:
parent
94fa482e0a
commit
9e16837b1b
@ -278,6 +278,7 @@ def main():
|
|||||||
if max_v * gain / 1000 <= int_ranges[idx]:
|
if max_v * gain / 1000 <= int_ranges[idx]:
|
||||||
range_index = idx
|
range_index = idx
|
||||||
break
|
break
|
||||||
|
print(ranges[range_index])
|
||||||
|
|
||||||
# if range_index >= len(ranges):
|
# if range_index >= len(ranges):
|
||||||
# range_index = len(ranges) - 1
|
# range_index = len(ranges) - 1
|
||||||
|
17
rasp_grid.py
17
rasp_grid.py
@ -60,6 +60,8 @@ def read_cfg(cfg_file, now, init_read=False):
|
|||||||
samplerate = int(float(line.split(':')[-1].strip().replace('kHz', '')) * 1000)
|
samplerate = int(float(line.split(':')[-1].strip().replace('kHz', '')) * 1000)
|
||||||
elif "AIMaxVolt" in line:
|
elif "AIMaxVolt" in line:
|
||||||
max_v = float(line.split(':')[1].strip().replace('mV', ''))
|
max_v = float(line.split(':')[1].strip().replace('mV', ''))
|
||||||
|
elif 'Gain' in line:
|
||||||
|
gain = int(line.split(':')[1].strip())
|
||||||
channels = n_rows * n_cols
|
channels = n_rows * n_cols
|
||||||
|
|
||||||
### alter information and re-write ###
|
### alter information and re-write ###
|
||||||
@ -75,7 +77,7 @@ def read_cfg(cfg_file, now, init_read=False):
|
|||||||
cfg_f.write(line)
|
cfg_f.write(line)
|
||||||
cfg_f.close()
|
cfg_f.close()
|
||||||
|
|
||||||
return channels, samplerate, max_v
|
return channels, samplerate, n_cols, n_rows, max_v, gain
|
||||||
|
|
||||||
# for line in cfg:
|
# for line in cfg:
|
||||||
# if 'Columns1' in line:
|
# if 'Columns1' in line:
|
||||||
@ -171,7 +173,7 @@ def main():
|
|||||||
cfgfile = os.path.join(path, 'fishgrid.cfg')
|
cfgfile = os.path.join(path, 'fishgrid.cfg')
|
||||||
|
|
||||||
# read and edit config file
|
# read and edit config file
|
||||||
channels, rate, max_v = read_cfg(cfgfile, now)
|
channels, rate, n_cols, n_rows, max_v, gain = read_cfg(init_cfgfile, now)
|
||||||
|
|
||||||
file = os.path.join(path, 'traces-grid1.raw')
|
file = os.path.join(path, 'traces-grid1.raw')
|
||||||
temp_file = os.path.join(path, 'temperatures.csv')
|
temp_file = os.path.join(path, 'temperatures.csv')
|
||||||
@ -260,8 +262,15 @@ def main():
|
|||||||
|
|
||||||
# Get a list of supported ranges and validate the range index.
|
# Get a list of supported ranges and validate the range index.
|
||||||
ranges = ai_info.get_ranges(input_mode)
|
ranges = ai_info.get_ranges(input_mode)
|
||||||
if range_index >= len(ranges):
|
int_ranges = []
|
||||||
range_index = len(ranges) - 1
|
for r in ranges:
|
||||||
|
int_ranges.append(int(r.name.replace('BIP', '').replace('VOLTS', '')))
|
||||||
|
|
||||||
|
for idx in np.argsort(int_ranges):
|
||||||
|
if max_v * gain / 1000 <= int_ranges[idx]:
|
||||||
|
range_index = idx
|
||||||
|
break
|
||||||
|
print(ranges[range_index])
|
||||||
|
|
||||||
# Allocate a buffer to receive the data.
|
# Allocate a buffer to receive the data.
|
||||||
data = create_float_buffer(channel_count, samples_per_channel)
|
data = create_float_buffer(channel_count, samples_per_channel)
|
||||||
|
Loading…
Reference in New Issue
Block a user