def setUp(self) -> None: self.managers = get_managers( enable_dax_sim(ddb=_DEVICE_DB, enable=True, logging_level=30, output='null', moninj_service=False))
def setUp(self) -> None: set_signal_manager(NullSignalManager()) self.managers = get_managers( enable_dax_sim(copy.deepcopy(self.DEVICE_DB), enable=True, logging_level=logging.WARNING, moninj_service=False, output='null'))
def setUp(self): self.core_arguments = self._DEVICE_DB['core']['arguments'] self.core_arguments.update(self._DEVICE_DB['core'].get('sim_args', {})) set_signal_manager(NullSignalManager()) self.managers = get_managers( enable_dax_sim(copy.deepcopy(self._DEVICE_DB), enable=True, logging_level=logging.WARNING, moninj_service=False, output='null'))
def setUp(self) -> None: # Create the system ddb = enable_dax_sim(_DEVICE_DB.copy(), enable=True, output='peek', moninj_service=False) self.managers = get_managers(ddb) self.sys = _TestSystem(self.managers) # Get the peek signal manager self.sm = typing.cast(PeekSignalManager, get_signal_manager()) self.assertIsInstance(self.sm, PeekSignalManager)
def test_ccb_tool(self): with get_managers() as managers: from dax.util.ccb import get_ccb_tool ccb = get_ccb_tool(_TestSystem(managers)) # Just call methods to see if no errors occur self.assertIsNone(ccb.big_number('name', 'key')) self.assertIsNone(ccb.image('name', 'key')) self.assertIsNone(ccb.plot_xy('name', 'key')) self.assertIsNone(ccb.plot_xy_multi('name', 'key')) self.assertIsNone(ccb.plot_hist('name', 'key')) self.assertIsNone(ccb.plot_hist_artiq('name', 'key')) self.assertIsNone(ccb.plot_xy_hist('name', 'key', 'key', 'key')) self.assertIsNone(ccb.disable_applet('name')) self.assertIsNone(ccb.disable_applet_group('group'))
def test_gtk_wave_save_generator(self): with temp_dir(): ddb = enable_dax_sim(ddb=_DEVICE_DB.copy(), enable=True, output='vcd', moninj_service=False) with get_managers(ddb) as managers: system = _TestSystem(managers) self.assertTrue(system.dax_sim_enabled) # Create GTKWave save generator object, which immediately writes the waves file GTKWSaveGenerator(system) # Manually close signal manager before leaving temp dir get_signal_manager().close()
def setUp(self) -> None: self._temp_dir = temp_dir() self._temp_dir.__enter__() # Create the system ddb = enable_dax_sim(_DEVICE_DB.copy(), enable=True, output='vcd', moninj_service=False) self.managers = get_managers(ddb) self.sys = _TestSystem(self.managers) # Get the signal manager self.sm: DaxSignalManager = typing.cast(VcdSignalManager, get_signal_manager()) self.assertIsInstance(self.sm, VcdSignalManager)
def test_gtk_wave_save_generator_invalid_signal_manager(self): with temp_dir(): ddb = enable_dax_sim(ddb=_DEVICE_DB.copy(), enable=True, output='null', moninj_service=False) with get_managers(ddb) as managers: system = _TestSystem(managers) self.assertTrue(system.dax_sim_enabled) with self.assertRaises( RuntimeError, msg='Not using VCD signal manager did not raise'): # Create GTKWave save generator object, which immediately writes the waves file GTKWSaveGenerator(system) # Manually close signal manager before leaving temp dir get_signal_manager().close()
def setUp(self) -> None: assert self.N > 0, 'Number of beams N should be > 0' self.managers = get_managers() self.s = _TestSystem(self.managers, num_beams=self.N) self.bm: BeamManager = self.s.m
def setUp(self) -> None: self.managers = get_managers(device_db=self._DEVICE_DB) self.cache = dax.sim.coredevice.cache.CoreCache(self.managers.device_mgr, cache=self._CACHE, _key='core_cache')
def setUp(self) -> None: self.managers = get_managers() self.sys = _TestSystem(self.managers)
def setUp(self) -> None: self.managers = get_managers() self.s = _TestSystem(self.managers) self.s.dax_init() self.t = self.s.time_resolved_context
def setUp(self) -> None: self.managers = get_managers() self.s = _TestSystem(self.managers) self.s.dax_init() self.h = self.s.hist_context
def setUp(self) -> None: self.managers = get_managers() self.s = self.SYSTEM_TYPE(self.managers) self.s.dax_init() self.counter = self.s.counter self.context = self.s.context
def setUp(self) -> None: self.managers = get_managers()
def setUp(self) -> None: self.managers = get_managers() self.scan: _MockScan1 = self.SCAN_CLASS(self.managers)
def setUp(self) -> None: self.managers = get_managers() self.scan = _MockScanStop(self.managers)
def setUp(self) -> None: self.managers = get_managers() self.scan = _MockScanTerminate(self.managers)
def _get_managers(**kwargs): return get_managers(enable_dax_sim(ddb=_DEVICE_DB, enable=True, logging_level=30, output='null', moninj_service=False), **kwargs)
def setUp(self) -> None: self.managers = get_managers(device_db=self._DEVICE_DB) self.generic = dax.sim.coredevice.generic.Generic( self.managers.device_mgr, _key='generic')
def construct_env( self, env_class: typing.Type[__E_T], *, device_db: typing.Union[str, typing.Dict[str, typing.Any], None] = None, logging_level: typing.Union[int, str] = logging.NOTSET, build_args: typing.Sequence[typing.Any] = (), build_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = None, env_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = None, **kwargs: typing.Any) -> __E_T: """Construct an ARTIQ environment based on the given class. The constructed environment can be used for testing. Devices in the device manager are automatically closed by a finalizer. It is not required to close the devices in the device manager explicitly. :param env_class: The environment class to construct :param device_db: The device DB to use (defaults to file configured in :attr:`DEFAULT_DEVICE_DB`) :param logging_level: The desired logging level :param build_args: Positional arguments passed to the build function of the environment :param build_kwargs: Keyword arguments passed to the build function of the environment :param env_kwargs: Keyword arguments passed to the argument parser of the environment :param kwargs: Keyword arguments passed to the argument parser of the environment (updates ``env_kwargs``) :return: The constructed ARTIQ environment object """ # Set default values if build_kwargs is None: build_kwargs = {} if env_kwargs is None: env_kwargs = {} assert issubclass( env_class, HasEnvironment ), 'The environment class must be a subclass of HasEnvironment' assert isinstance( device_db, (str, dict) ) or device_db is None, 'Device DB must be of type str, dict, or None' assert isinstance( logging_level, (int, str)), 'Logging level must be of type int or str' assert isinstance( build_args, collections.abc.Sequence), 'Build arguments must be a sequence' assert isinstance(build_kwargs, dict), 'Build keyword arguments must be a dict' assert all( isinstance(k, str) for k in build_kwargs), 'Keys of the build kwargs dict must be of type str' assert isinstance(env_kwargs, dict), 'Environment keyword arguments must be a dict' # Set level of module logger _logger.setLevel(logging_level) # Construct an expid object expid: typing.Dict[str, typing.Any] = { 'log_level': logging_level, 'class_name': env_class.__name__, 'repo_rev': 'N/A' } if isinstance(device_db, dict): # Copy the device DB to not mutate the given one device_db = device_db.copy() else: # Obtain device DB from file _logger.debug('Obtaining device DB from file') with warnings.catch_warnings(): # Ignore resource warnings that could be raised from evaluating the device DB # These warnings appear when starting the MonInjDummyService warnings.simplefilter('ignore', category=ResourceWarning) device_db = device_db_from_file( self.DEFAULT_DEVICE_DB if device_db is None else device_db) # Convert and configure device DB _logger.debug('Converting device DB') enable_dax_sim(ddb=device_db, enable=True, logging_level=logging_level, output='peek', moninj_service=False) # Construct environment, which will also construct a new signal manager _logger.debug('Constructing environment') env = env_class( get_managers(device_db, expid=expid, arguments=env_kwargs, **kwargs), *build_args, **build_kwargs) # Store the new signal manager _logger.debug('Retrieving peek signal manager') self.__signal_manager = typing.cast(PeekSignalManager, get_signal_manager()) assert isinstance( self.__signal_manager, PeekSignalManager), 'Did not obtained correct signal manager type' # Return the environment return env
def setUp(self) -> None: ddb = enable_dax_sim(_DEVICE_DB.copy(), enable=True, output='null', moninj_service=False) self.managers = get_managers(ddb)