def test_WHEN_loading_invalid_beamline_configuration_file_THEN_status_PV_shows_error( self): beamline_configuration.REFL_CONFIG_PATH = PATH_TO_CONFGIS beamline = beamline_configuration.create_beamline_from_configuration( {"CONFIG_FILE": "invalid_config.py"}) # Check Status PV self.assertEqual( STATUS.ERROR, ReflectometryServer.server_status_manager.STATUS_MANAGER.status)
def test_WHEN_loading_valid_beamline_configuration_file_THEN_correct_PVs_are_created( self): beamline_configuration.REFL_CONFIG_PATH = PATH_TO_CONFGIS beamline = beamline_configuration.create_beamline_from_configuration( {}) # Check Status PV self.assertEqual( STATUS.OKAY, ReflectometryServer.server_status_manager.STATUS_MANAGER.status)
def test_GIVEN_optional_macro_not_set_WHEN_loading_config_THEN_optional_items_not_part_of_config( self): beamline_configuration.REFL_CONFIG_PATH = PATH_TO_CONFGIS beamline = beamline_configuration.create_beamline_from_configuration( {"OPTIONAL_1": "False"}) # Check Status PV self.assertEqual( STATUS.OKAY, ReflectometryServer.server_status_manager.STATUS_MANAGER.status) self.assertTrue(OPTIONAL_PARAM_1 not in beamline.parameters.keys())
def test_GIVEN_valid_other_config_file_in_macro_WHEN_loading_config_THEN_other_config_is_loaded( self): beamline_configuration.REFL_CONFIG_PATH = PATH_TO_CONFGIS beamline = beamline_configuration.create_beamline_from_configuration( {"CONFIG_FILE": "other_config.py"}) # Check Status PV self.assertEqual( STATUS.OKAY, ReflectometryServer.server_status_manager.STATUS_MANAGER.status) self.assertTrue(OTHER_CONFIG_PARAM in beamline.parameters.keys())
def test_WHEN_loading_beamline_configuration_file_that_doesnt_exist_THEN_status_PV_shows_import_error( self): beamline_configuration.REFL_CONFIG_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), "refl")) with patch("ReflectometryServer.beamline_configuration.import_module", side_effect=ImportError("")) as import_fn: beamline = beamline_configuration.create_beamline_from_configuration( {}) # Check Status PV self.assertEqual( STATUS.ERROR, ReflectometryServer.server_status_manager.STATUS_MANAGER.status)
# Run heartbeat IOC, this is done with a different prefix SERVER.createPV(prefix="{pv_prefix}CS:IOC:{ioc_name}:DEVIOS:".format( pv_prefix=MYPVPREFIX, ioc_name=REFL_IOC_NAME), pvdb={"HEARTBEAT": { "type": "int", "value": 0 }}) driver = ReflectometryDriver(SERVER, pv_manager) process_ca_thread = Thread(target=process_ca_loop) process_ca_thread.daemon = True process_ca_thread.start() logger.info("Instantiating Beamline Model") beamline = create_beamline_from_configuration(get_macro_values()) pv_manager.set_beamline(beamline) # Do not re-create PVs that already exist pvdb_to_add = pv_manager.get_init_filtered_pvdb() SERVER.createPV(REFLECTOMETRY_PREFIX, pvdb_to_add) driver.set_beamline(beamline) register_ioc_start(REFL_IOC_NAME, pv_manager.PVDB, REFLECTOMETRY_PREFIX) logger.info("Reflectometry IOC started.") # Process CA transactions process_ca_thread.join()