Esempio n. 1
0
 def test_glbl_reload(self):
     # fresh start, test default values
     for k, v in glbl_dict.items():
         assert self._glbl[k] == v
     # update value
     self._glbl["dk_window"] = 20
     self._glbl["auto_dark"] = False
     self._glbl["_dark_dict_list"] = [{
         "acq_time": 0.1,
         "exposure": 0.5,
         "timestamp": time.time(),
         "uid": str(uuid.uuid4()),
     }]
     # after update, local yaml should exist
     assert os.path.isfile(self._glbl["glbl_yaml_path"])
     reload_glbl_dict = _reload_glbl()
     # test contents of reload dict
     for k, v in self._glbl.items():
         assert reload_glbl_dict[k] == v
     # test equality of glbl objects after setting contents
     reload_glbl = GlblYamlDict("glbl", **glbl_dict)
     _set_glbl(reload_glbl, reload_glbl_dict)
     assert reload_glbl == self._glbl
                 robot=robot
                 )

# cache previous glbl state
reload_glbl_dict = _reload_glbl()
from xpdacq.glbl import glbl

# reload beamtime
from xpdacq.beamtimeSetup import (start_xpdacq, _start_beamtime,
                                  _end_beamtime)

bt = start_xpdacq()
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