Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions exopy_hqc_legacy/instruments/drivers/dll/sp_adq14.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ def destroy_board(self, b_id):
self.library.ControlUnit_DeleteADQ(self.id, b_id)
del self._boards[b_id-1]

def enable_logging(self, level, path):
"""
"""
self.library.ControlUnit_EnableErrorTrace(self.id, level, path)

def _cleanup(self):
"""Make sure we disconnect all the boards and destroy the unit.

Expand Down Expand Up @@ -99,6 +104,7 @@ def open_connection(self):

"""
cu = ADQControlUnit(self._dll)
cu.enable_logging(3, b"C:\\Logs")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ugly ! We should pass a path for logging to the instrument as part of its setting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the very least it should be behind an os check (the ADQ can run linux) and we should try to get a user related path that is more likely to be writable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just a quick hack I wrote to debug the issues I was having. It can be safely removed from this patch. (And added cleanly in the future)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean added cleanly ? is this needed or not ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed, I added this to debug an issue with the sp_adq14. What I meant by added cleanly was the fact that we could have a settings somewhere to toggle logging on and off where we could choose the logging directory instead of hard coding all of that.

boards = cu.list_boards()
board_id = None
for i, b in enumerate(boards):
Expand Down Expand Up @@ -216,6 +222,8 @@ def get_traces(self, channels, duration, delay, records_per_capture,
get_data = self._dll.GetData.func
retrieved_records = 0
while retrieved_records < records_per_capture:
# WHY ???
time.sleep(0.002)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why indeed? Depending on the length of the traces this could lead to a large accumulation of traces and slow down the acquisition.

Copy link
Contributor

@rassouly rassouly Jun 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fix for various intermittent and hard to debug issues we had and it was absolutely needed for us at the time. I suspect that this solves some sort of race condition. It's very hard to reproduce and the issue probably comes from the dll driver itself. The time we chose is a compromise between the frequency of crashes and the speed of the measurement so I think this should stay in the local cryofree version but it shouldn't go on the master branch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have the log, you could contact the manufacturer. Last time it took about an afternoon to fix the bug.

# Wait for a record to be acquired.
n_records = (acq_records(cu, id_) - retrieved_records)

Expand Down
2 changes: 1 addition & 1 deletion exopy_hqc_legacy/instruments/drivers/driver_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ def wait_for_completion(self, break_condition_callable=None, timeout=15,
while True:
remaining_time = (timeout -
(time.time() - timeout_start))
time.sleep(min(refresh_time, remaining_time))
if self.condition_callable():
return True
if remaining_time < 0 or break_condition_callable():
return False
time.sleep(min(refresh_time, remaining_time))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is meaningless, we check the condition before entering the while loop so checking again after a couple of operations won't do any good.


def cancel(self, *args, **kwargs):
"""Cancel the long running job.
Expand Down
2 changes: 1 addition & 1 deletion exopy_hqc_legacy/instruments/drivers/visa/agilent_psa.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
#==============================================================================
# module : agilent_psa.py
# author : Benjamin Huard
# license : MIT license
#==============================================================================
"""
Expand Down Expand Up @@ -190,6 +189,7 @@ def mode(self):
"""
"""
SAorBASIC = self.ask('inst:sel?')
SAorBASIC = SAorBASIC[:-1]
if SAorBASIC == 'SA':
return 'SA'
elif SAorBASIC == 'BASIC':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ def open_connection(self, **para):
# set lower limit to lowest value
self.write('LLIM -7')

@secure_communication()
def read_output_field(self):
"""Read the current value of the output field.

"""
return float(self.ask('IOUT?').strip(' T'))

@secure_communication()
def read_persistent_field(self):
"""Read the current value of the persistent field.

Expand Down Expand Up @@ -132,6 +134,7 @@ def check_connection(self):
pass

@instrument_property
@secure_communication()
def heater_state(self):
"""State of the switch heater allowing to inject current into the
coil.
Expand All @@ -151,6 +154,7 @@ def heater_state(self, state):
sleep(1)

@instrument_property
@secure_communication()
def field_sweep_rate(self):
"""Rate at which to ramp the field (T/min).

Expand All @@ -167,6 +171,7 @@ def field_sweep_rate(self, rate):
self.write('RATE 0 {}'.format(rate))

@instrument_property
@secure_communication()
def fast_sweep_rate(self):
"""Rate at which to ramp the field when the switch heater is off
(T/min).
Expand All @@ -182,6 +187,7 @@ def fast_sweep_rate(self, rate):
self.write('RATE 3 {}'.format(rate))

@instrument_property
@secure_communication()
def target_field(self):
"""Field that the source will try to reach.

Expand All @@ -199,13 +205,15 @@ def target_field(self, target):
self.write('ULIM {}'.format(target))

@instrument_property
@secure_communication()
def persistent_field(self):
"""Last known value of the magnet field.

"""
return float(self.ask('IMAG?').strip(' T'))

@instrument_property
@secure_communication()
def activity(self):
"""Current activity of the power supply (idle, ramping).

Expand Down
17 changes: 10 additions & 7 deletions exopy_hqc_legacy/instruments/drivers/visa_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def open_connection(self, **para):

"""
rm = ResourceManager()

self.para = para

try:
self._driver = rm.open_resource(self.connection_str,
open_timeout=1000, **para)
Expand All @@ -116,13 +119,13 @@ def reopen_connection(self):
as previously.

"""
para = {'timeout': self._driver.timeout,
'query_delay': self._driver.query_delay,
'write_termination': self._driver.write_termination,
'read_termination': self._driver.read_termination,
}
self._driver.close()
self.open_connection(**para)
# para = {'timeout': self._driver.timeout,
# 'query_delay': self._driver.query_delay,
# 'write_termination': self._driver.write_termination,
# 'read_termination': self._driver.read_termination,
# }
# self._driver.close()
self.open_connection(**self.para)

def connected(self):
"""Returns whether commands can be sent to the instrument
Expand Down
17 changes: 17 additions & 0 deletions exopy_hqc_legacy/manifest.enaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ enamldef HqcLegacyManifest(PluginManifest):
'VisaUSB': {'resource_class': 'INSTR'},
'VisaTCPIP': {'resource_class': 'INSTR'}
}
Driver:
driver = 'agilent_psa:AgilentPSA'
serie = ''
model = 'E4440A'
kind = 'Spectrum analyser'
connections = {'VisaGPIB': {'resource_class': 'INSTR'},
'VisaUSB': {'resource_class': 'INSTR'},
'VisaTCPIP': {'resource_class': 'INSTR'}
}
Drivers:
manufacturer = 'Yokogawa'
Driver:
Expand Down Expand Up @@ -423,6 +432,14 @@ enamldef HqcLegacyManifest(PluginManifest):
view = 'views.rf_views:PulseModulationView'
instruments = ['exopy_hqc_legacy.Legacy.RohdeSchwarzSMB100A',
'exopy_hqc_legacy.Legacy.Anapico']
Task:
task = 'psa_tasks:PSAGetTrace'
view = 'views.psa_tasks_views:PSAGetTraceView'
instruments = ['exopy_hqc_legacy.Legacy.AgilentPSA']
Task:
task = 'psa_tasks:PSASetParam'
view = 'views.psa_tasks_views:PSASetParamView'
instruments = ['exopy_hqc_legacy.Legacy.AgilentPSA']
Task:
task = 'pna_tasks:PNASinglePointMeasureTask'
view = 'views.pna_task_views:PNASinglePointView'
Expand Down
25 changes: 13 additions & 12 deletions exopy_hqc_legacy/tasks/tasks/instr/psa_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


from exopy.tasks.api import InstrumentTask, validators
from exopy.tasks.api import InstrumentTask, TaskInterface, validators

# XXX unfinished

Expand Down Expand Up @@ -48,7 +49,7 @@ def perform(self):
psa_config = header.format(d.start_frequency_SA, d.stop_frequency_SA,
d.span_frequency, d.center_frequency,
d.average_count_SA, d.RBW, d.VBW_SA,
d.sweep_points_SA, sweep_modes[self.mode])
d.sweep_points_SA, sweep_modes[d.mode])

self.write_in_database('psa_config', psa_config)
self.write_in_database('trace_data', self.driver.read_data(self.trace))
Expand Down Expand Up @@ -108,9 +109,9 @@ def perform(self):
self.driver.start_frequency_SA = \
self.format_and_eval_string(self.start_freq)

if self.stop_freq:
if self.end_freq:
self.driver.stop_frequency_SA = \
self.format_and_eval_string(self.stop_freq)
self.format_and_eval_string(self.end_freq)

# start_freq is set again in case the former value of stop
# prevented to do it
Expand Down Expand Up @@ -155,14 +156,14 @@ def perform(self):
{}'''.format(d.start_frequency_SA, d.stop_frequency_SA,
d.span_frequency, d.center_frequency,
d.average_count_SA, d.RBW, d.VBW_SA,
d.sweep_points_SA, sweep_modes[self.mode])
d.sweep_points_SA, sweep_modes[d.mode])

self.write_in_database('psa_config', psa_config)

def check(self, *args, **kwargs):
"""
"""
test, traceback = super(PSAGetTrace, self).check(*args, **kwargs)
test, traceback = super(PSASetParam, self).check(*args, **kwargs)

err_path = self.get_error_path()

Expand All @@ -177,7 +178,7 @@ def check(self, *args, **kwargs):
start = self.format_and_eval_string(self.start_freq)
# if type(self.driver).__name__ == 'AgilentPSA':
# is a new PSA needs to be encoded, it would be best to use task_interfaces
if (start < 3) or (start > 26500000000):
if (start < 0) or (start > 26500000000):
raise Exception('out_of_range')

except Exception as e:
Expand All @@ -192,21 +193,21 @@ def check(self, *args, **kwargs):
'formula {}'.format(self.start_freq)

try:
if self.stop_freq:
toto = self.format_and_eval_string(self.stop_freq)
if (toto < 3) or (toto > 26500000000):
if self.end_freq:
toto = self.format_and_eval_string(self.end_freq)
if (toto < 0) or (toto > 26500000000):
raise Exception('out_of_range')

except Exception as e:
test = False
if e.args == 'out_of_range':
traceback[err_path +
'-stop_freq'] = 'Stop frequency {} out of ' + \
'-end_freq'] = 'Stop frequency {} out of ' + \
'range'.format(self.start_freq)
else:
traceback[err_path +
'-stop_freq'] = 'Failed to eval the stop' + \
'formula {}'.format(self.stop_freq)
'-end_freq'] = 'Failed to eval the stop' + \
'formula {}'.format(self.end_freq)
else:
try:
if self.span_freq:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ from enaml.core.api import Conditional
from enaml.widgets.api import (GroupBox, Label, Field, ObjectCombo, CheckBox)
from enaml.layout.api import factory

from exopy.tasks.api import InstrView, EVALUATER_TOOLTIP
from exopy.tasks.api import EVALUATER_TOOLTIP
from exopy.utils.widgets.qt_completers import QtLineCompleter
from exopy_hqc_legacy.utils.layouts import auto_grid_layout
from ..base_instr_view import InstrView
from ...base_instr_view import InstrView


# XXX unfinished

Expand Down
4 changes: 2 additions & 2 deletions exopy_hqc_legacy/tasks/tasks/util/load_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def perform(self):
break

data = np.genfromtxt(full_path, comments=self.comments,
delimiter=self.delimiter, names=self.names,
delimiter=self.delimiter, names=self.names if self.names else None,
skip_header=comment_lines)

task.write_in_database('array', data)
Expand Down Expand Up @@ -140,5 +140,5 @@ def _post_setattr_c_names(self, old, new):
"""Keep the c_names in sync with the array in the database.

"""
if new:
if new and self.task:
self.task.write_in_database('array', _make_array(new))