def __init__(self, resource_name=None, name="Unlabeled APS2"): self.name = name self.resource_name = resource_name if aps2_missing: logger.warning("Could not load aps2 library") if fake_aps2: self.wrapper = MagicMock() else: self.wrapper = aps2.APS2() self.set_enabled = self.wrapper.set_channel_enabled self.set_mixer_phase_skew = self.wrapper.set_mixer_phase_skew self.set_mixer_amplitude_imbalance = self.wrapper.set_mixer_amplitude_imbalance self.get_amplitude = self.wrapper.get_channel_scale self.get_offset = self.wrapper.get_channel_offset self.get_enabled = self.wrapper.get_channel_enabled self.get_mixer_phase_skew = self.wrapper.get_mixer_phase_skew self.get_mixer_amplitude_imbalance = self.wrapper.get_mixer_amplitude_imbalance self.run = self.wrapper.run self.stop = self.wrapper.stop self.connected = False self._sequence_filename = None self._mode = "RUN_SEQUENCE" if not fake_aps2: self._mode_dict = aps2.run_mode_dict self._mode_inv_dict = {v: k for k, v in aps2.run_mode_dict.items()}
def __init__(self, resource_name, name="Unlabeled APS2"): self.name = name self.resource_name = resource_name if fake_aps2: self.wrapper = MagicMock() else: self.wrapper = aps2.APS2() self.set_amplitude = self.wrapper.set_channel_scale self.set_offset = self.wrapper.set_channel_offset self.set_enabled = self.wrapper.set_channel_enabled self.get_amplitude = self.wrapper.get_channel_scale self.get_offset = self.wrapper.get_channel_offset self.get_enabled = self.wrapper.get_channel_enabled self.run = self.wrapper.run self.stop = self.wrapper.stop self.connected = False
import sys import os import numpy as np #assume this is run from /examples and add ../src/python to path import sys import os examples_path = os.path.abspath(os.path.dirname(__file__)) aps2_module_path = os.path.join(os.path.dirname(examples_path), "src/python") if aps2_module_path not in sys.path: sys.path.append(aps2_module_path) import aps2 aps = aps2.APS2() aps.connect(str(sys.argv[1])) uptime = aps.get_uptime() firmware_version = aps.get_firmware_version() print("Connected to APS2 running firmware version {} and up {} seconds".format(firmware_version[3], uptime)) aps.init() aps.set_trigger_source(aps2.INTERNAL) aps.set_trigger_interval(20e-3) print("Playing ramp waveforms") aps.set_waveform_float(0, np.linspace(-1,1, 2**14, dtype=np.float32)) aps.set_waveform_float(1, np.linspace(1,-1, 2**14, dtype=np.float32)) aps.set_run_mode(aps2.TRIG_WAVEFORM) aps.run() input("Press Enter to continue...")