Skip to content

Commit

Permalink
Fix extremely bad merge conflict resolution from #70.
Browse files Browse the repository at this point in the history
dihm committed Nov 18, 2021
1 parent 0767130 commit be71723
Showing 1 changed file with 25 additions and 125 deletions.
150 changes: 25 additions & 125 deletions labscript_devices/NI_DAQmx/models/get_capabilities.py
Original file line number Diff line number Diff line change
@@ -509,6 +509,16 @@ def get_min_semiperiod_measurement(device_name):
multi_rate = None
capabilities[model]["max_AI_single_chan_rate"] = single_rate
capabilities[model]["max_AI_multi_chan_rate"] = multi_rate
if capabilities[model]["num_AI"] > 0:
capabilities[model]["AI_term_cfg"] = supported_AI_terminal_configurations(name)
cfgs = [item for sublist in capabilities[model]["AI_term_cfg"].values() for item in sublist]
if cfgs.count('RSE'):
capabilities[model]["AI_term"] = 'RSE'
elif cfgs.count('Diff'):
capabilities[model]["AI_term"] = 'Diff'
elif cfgs.count('PseudoDiff'):
capabilities[model]["AI_term"] = 'PseudoDiff'
capabilities[model]["supports_simultaneous_AI_sampling"] = DAQmxGetDevAISimultaneousSamplingSupported(name)

capabilities[model]["ports"] = {}
ports = DAQmxGetDevDOPorts(name)
@@ -558,142 +568,32 @@ def get_min_semiperiod_measurement(device_name):
for i in range(0, len(raw_limits), 2):
Vmin, Vmax = raw_limits[i], raw_limits[i + 1]
AI_ranges.append([Vmin, Vmax])
# Restrict to the ranges allowed for non-differential input:
AI_ranges = supported_AI_ranges_for_non_differential_input(name, AI_ranges)
# Find range with the largest maximum voltage and use that:
Vmin, Vmax = max(AI_ranges, key=lambda range: range[1])
Vmin_raw, Vmax_raw = max(AI_ranges, key=lambda range: range[1])
# Confirm that no other range has a voltage lower than Vmin,
# since if it does, this violates our assumptions and things might not
# be as simple as having a single range:
assert min(AI_ranges)[0] >= Vmin_raw
capabilities[model]["AI_range_Diff"] = [Vmin_raw, Vmax_raw]
if 'RSE' in capabilities[model]["AI_term_cfg"]['ai0']:
# Now limit to non-differential inputs (if available), which may have lower ranges
AI_ranges = supported_AI_ranges_for_non_differential_input(name, AI_ranges)
# Find RSE range with the largest maximum voltage and use that:
Vmin, Vmax = max(AI_ranges, key=lambda range: range[1])
assert min(AI_ranges)[0] >= Vmin
capabilities[model]["AI_range"] = [Vmin, Vmax]
else:
capabilities[model]["AI_range"] = None
capabilities = json.load(f)
except ValueError:
pass


models = []
for name in DAQmxGetSysDevNames().split(', '):
# ignore extra details in model names
model = DAQmxGetDevProductType(name).split(' ')[0]
print("found device:", name, model)
if model not in models:
models.append(model)
capabilities[model] = {}
try:
capabilities[model]["supports_buffered_AO"] = DAQmxGetDevAOSampClkSupported(
name
)
except PyDAQmx.DAQmxFunctions.AttrNotSupportedError:
capabilities[model]["supports_buffered_AO"] = False
try:
capabilities[model]["max_DO_sample_rate"] = DAQmxGetDevDOMaxRate(name)
capabilities[model]["supports_buffered_DO"] = True
except PyDAQmx.DAQmxFunctions.AttrNotSupportedError:
capabilities[model]["max_DO_sample_rate"] = None
capabilities[model]["supports_buffered_DO"] = False
if capabilities[model]["supports_buffered_AO"]:
capabilities[model]["max_AO_sample_rate"] = DAQmxGetDevAOMaxRate(name)
else:
capabilities[model]["max_AO_sample_rate"] = None
capabilities[model]["AI_range_Diff"] = None

capabilities[model]["num_AO"] = len(DAQmxGetDevAOPhysicalChans(name))
capabilities[model]["num_AI"] = len(DAQmxGetDevAIPhysicalChans(name))
if capabilities[model]["num_AI"] > 0:
single_rate = DAQmxGetDevAIMaxSingleChanRate(name)
multi_rate = DAQmxGetDevAIMaxMultiChanRate(name)
else:
single_rate = None
multi_rate = None
capabilities[model]["max_AI_single_chan_rate"] = single_rate
capabilities[model]["max_AI_multi_chan_rate"] = multi_rate
if capabilities[model]["num_AI"] > 0:
capabilities[model]["AI_term_cfg"] = supported_AI_terminal_configurations(name)
cfgs = [item for sublist in capabilities[model]["AI_term_cfg"].values() for item in sublist]
if cfgs.count('RSE'):
capabilities[model]["AI_term"] = 'RSE'
elif cfgs.count('Diff'):
capabilities[model]["AI_term"] = 'Diff'
elif cfgs.count('PseudoDiff'):
capabilities[model]["AI_term"] = 'PseudoDiff'
capabilities[model]["supports_simultaneous_AI_sampling"] = DAQmxGetDevAISimultaneousSamplingSupported(name)

capabilities[model]["ports"] = {}
ports = DAQmxGetDevDOPorts(name)
chans = DAQmxGetDevDOLines(name)
for port in ports:
if '_' in port:
# Ignore the alternate port names such as 'port0_32' that allow using two or
# more ports together as a single, larger one:
continue
port_info = {}
capabilities[model]["ports"][port] = port_info
port_chans = [chan for chan in chans if chan.split('/')[0] == port]
port_info['num_lines'] = len(port_chans)
if capabilities[model]["supports_buffered_DO"]:
port_info['supports_buffered'] = port_supports_buffered(name, port)
if capabilities[model]["num_AI"] > 0:
if capabilities[model]["AI_term"] == 'PseudoDiff':
capabilities[model]["AI_start_delay_ticks"] = AI_filter_delay(name)
capabilities[model]["AI_start_delay"] = None
else:
capabilities[model]["AI_start_delay"] = AI_start_delay(name)
else:
port_info['supports_buffered'] = False

capabilities[model]["num_CI"] = len(DAQmxGetDevCIPhysicalChans(name))
supports_semiperiod = supports_semiperiod_measurement(name)
capabilities[model]["supports_semiperiod_measurement"] = supports_semiperiod
if capabilities[model]["num_CI"] > 0 and supports_semiperiod:
min_semiperiod_measurement = get_min_semiperiod_measurement(name)
else:
min_semiperiod_measurement = None
capabilities[model]["min_semiperiod_measurement"] = min_semiperiod_measurement

if capabilities[model]['num_AO'] > 0:
AO_ranges = []
raw_limits = DAQmxGetDevAOVoltageRngs(name)
for i in range(0, len(raw_limits), 2):
Vmin, Vmax = raw_limits[i], raw_limits[i + 1]
AO_ranges.append([Vmin, Vmax])
# Find range with the largest maximum voltage and use that:
Vmin, Vmax = max(AO_ranges, key=lambda range: range[1])
# Confirm that no other range has a voltage lower than Vmin,
# since if it does, this violates our assumptions and things might not
# be as simple as having a single range:
assert min(AO_ranges)[0] >= Vmin
capabilities[model]["AO_range"] = [Vmin, Vmax]
else:
capabilities[model]["AO_range"] = None

if capabilities[model]['num_AI'] > 0:
AI_ranges = []
raw_limits = DAQmxGetDevAIVoltageRngs(name)
for i in range(0, len(raw_limits), 2):
Vmin, Vmax = raw_limits[i], raw_limits[i + 1]
AI_ranges.append([Vmin, Vmax])
# Find range with the largest maximum voltage and use that:
Vmin_raw, Vmax_raw = max(AI_ranges, key=lambda range: range[1])
# Confirm that no other range has a voltage lower than Vmin,
# since if it does, this violates our assumptions and things might not
# be as simple as having a single range:
assert min(AI_ranges)[0] >= Vmin_raw
capabilities[model]["AI_range_Diff"] = [Vmin_raw, Vmax_raw]
if 'RSE' in capabilities[model]["AI_term_cfg"]['ai0']:
# Now limit to non-differential inputs (if available), which may have lower ranges
AI_ranges = supported_AI_ranges_for_non_differential_input(name, AI_ranges)
# Find RSE range with the largest maximum voltage and use that:
Vmin, Vmax = max(AI_ranges, key=lambda range: range[1])
assert min(AI_ranges)[0] >= Vmin
capabilities[model]["AI_range"] = [Vmin, Vmax]
else:
capabilities[model]["AI_range"] = None
capabilities[model]["AI_range_Diff"] = None

if capabilities[model]["num_AI"] > 0:
if capabilities[model]["AI_term"] == 'PseudoDiff':
capabilities[model]["AI_start_delay_ticks"] = AI_filter_delay(name)
capabilities[model]["AI_start_delay"] = None
else:
capabilities[model]["AI_start_delay"] = AI_start_delay(name)
else:
capabilities[model]["AI_start_delay"] = None


with open(CAPABILITIES_FILE, 'w', newline='\n') as f:

0 comments on commit be71723

Please sign in to comment.