Esempio n. 1
0
 def test_load_beamline_config(self):
     # no beamline config -> raise
     if os.path.exists(glbl["blconfig_path"]):
         os.remove(glbl["blconfig_path"])
     with self.assertRaises(xpdAcqException):
         _load_beamline_config(glbl["blconfig_path"], test=True)
     # move files
     stem, fn = os.path.split(glbl["blconfig_path"])
     src = os.path.join(pytest_dir, fn)
     shutil.copyfile(src, glbl["blconfig_path"])
     beamline_config_dict = _load_beamline_config(glbl["blconfig_path"],
                                                  test=True)
     assert "is_pytest" in beamline_config_dict
     # check md -> only is_pytest in template now
     self.xrun.md["beamline_config"] = beamline_config_dict
     self.xrun({}, ScanPlan(self.bt, ct, 1.0))
     hdr = xpd_configuration["db"][-1]
     print(beamline_config_dict)
     assert hdr.start["beamline_config"] == beamline_config_dict
if bt is not None:
    print("INFO: Reload beamtime objects:\n{}\n".format(bt))
if reload_glbl_dict is not None:
    _set_glbl(glbl, reload_glbl_dict)

# import necessary modules
from xpdacq.xpdacq import *
from xpdacq.beamtime import *
from xpdacq.utils import import_sample_info

# instantiate xrun without beamtime, like bluesky setup
xrun = CustomizedRunEngine(None)
xrun.md['beamline_id'] = glbl['beamline_id']
xrun.md['group'] = glbl['group']
xrun.md['facility'] = glbl['facility']
beamline_config = _load_beamline_config(glbl['blconfig_path'])
xrun.md['beamline_config'] = beamline_config

# insert header to db, either simulated or real
xrun.subscribe(db.insert, 'all')

# robot command
xrun.register_command('load_sample', _load_sample)
xrun.register_command('unload_sample', _unload_sample)

if bt:
    xrun.beamtime = bt

HOME_DIR = glbl['home']
BASE_DIR = glbl['base']
Esempio n. 3
0
if bt is not None:
    print("INFO: Reload beamtime objects:\n{}\n".format(bt))
if reload_glbl_dict is not None:
    _set_glbl(glbl, reload_glbl_dict)

# import necessary modules
from xpdacq.xpdacq import *
from xpdacq.beamtime import *
from xpdacq.utils import import_sample_info

# instantiate xrun without beamtime, like bluesky setup
xrun = CustomizedRunEngine(None)
xrun.md["beamline_id"] = glbl["beamline_id"]
xrun.md["group"] = glbl["group"]
xrun.md["facility"] = glbl["facility"]
beamline_config = _load_beamline_config(glbl["blconfig_path"])
xrun.md["beamline_config"] = beamline_config

# insert header to db, either simulated or real
xrun.subscribe(db.insert, "all")

if bt:
    xrun.beamtime = bt

HOME_DIR = glbl["home"]
BASE_DIR = glbl["base"]

print("INFO: Initializing the XPD data acquisition environment\n")
if os.path.isdir(HOME_DIR):
    os.chdir(HOME_DIR)
else: