Exemplo n.º 1
0
def load_config(args, name_suffix=""):
    """ load configuration file, restoring from backup if necessary cf
    config_args
    """
    config_path, backup_path = get_config_path(args, name_suffix)
    try:
        config = pyon.load_file(config_path)
    except FileNotFoundError:
        logger.warning("Unable to find server configuration file, "
                       "restoring from backup")
        shutil.copyfile(backup_path, config_path)
        config = pyon.load_file(config_path)
    return config
Exemplo n.º 2
0
 def __init__(self, pattern_file):
     self.pattern_file = pattern_file
     self.patterns = []
     try:
         self.patterns = pyon.load_file(self.pattern_file)
     except FileNotFoundError:
         logger.info("no pattern file found, logging everything")
Exemplo n.º 3
0
 def _load_setpoints(self):
     """Load setpoints from a file"""
     try:
         self.channels = pyon.load_file(self.fname)
         logger.info("Loaded '{}', channels: {}".format(self.fname, self.channels))
     except FileNotFoundError:
         logger.warning("Couldn't find '{}', no setpoints loaded".format(self.fname))
Exemplo n.º 4
0
 def __init__(self, pattern_file):
     self.pattern_file = pattern_file
     self.patterns = []
     try:
         self.patterns = pyon.load_file(self.pattern_file)
     except FileNotFoundError:
         logger.info("no pattern file found, logging everything")
Exemplo n.º 5
0
    def __init__(self, persist_file, autosave_period=30):
        self.persist_file = persist_file
        self.autosave_period = autosave_period

        try:
            file_data = pyon.load_file(self.persist_file)
        except FileNotFoundError:
            file_data = dict()
        self.data = Notifier({k: (True, v) for k, v in file_data.items()})
Exemplo n.º 6
0
 def _load_setpoints(self):
     """Load setpoints from a file"""
     try:
         self.channels = pyon.load_file(self.fname)
         logger.info("Loaded '{}', channels: {}".format(
             self.fname, self.channels))
     except FileNotFoundError:
         logger.warning("Couldn't find '{}', no setpoints loaded".format(
             self.fname))
Exemplo n.º 7
0
    def scan(self):
        new_data = pyon.load_file(self.backing_file)

        for k in list(self.data.read.keys()):
            if k not in new_data:
                del self.data[k]
        for k in new_data.keys():
            if k not in self.data.read or self.data.read[k] != new_data[k]:
                self.data[k] = new_data[k]
Exemplo n.º 8
0
    def __init__(self, persist_file, autosave_period=30):
        self.persist_file = persist_file
        self.autosave_period = autosave_period

        try:
            file_data = pyon.load_file(self.persist_file)
        except FileNotFoundError:
            file_data = dict()
        self.data = Notifier({k: (True, v) for k, v in file_data.items()})
Exemplo n.º 9
0
    def scan(self):
        new_data = pyon.load_file(self.backing_file)

        for k in list(self.data.read.keys()):
            if k not in new_data:
                del self.data[k]
        for k in new_data.keys():
            if k not in self.data.read or self.data.read[k] != new_data[k]:
                self.data[k] = new_data[k]
Exemplo n.º 10
0
 def __init__(self, filename, default_data=None):
     self.filename = filename
     try:
         data = pyon.load_file(self.filename)
     except FileNotFoundError:
         if default_data is None:
             raise
         else:
             data = default_data
     self.data = Notifier(data)
     self.hooks = []
Exemplo n.º 11
0
def get_from_ddb(*path, default="skip"):
    if not artiq_root:
        raise unittest.SkipTest("no ARTIQ_ROOT")
    v = pyon.load_file(os.path.join(artiq_root, "device_db.pyon"))
    try:
        for p in path:
            v = v[p]
        return v.read
    except KeyError:
        if default == "skip":
            raise unittest.SkipTest("device db path {} not found".format(path))
        else:
            return default
Exemplo n.º 12
0
def get_from_ddb(*path, default="skip"):
    if not artiq_root:
        raise unittest.SkipTest("no ARTIQ_ROOT")
    v = pyon.load_file(os.path.join(artiq_root, "device_db.pyon"))
    try:
        for p in path:
            v = v[p]
        return v.read
    except KeyError:
        if default == "skip":
            raise unittest.SkipTest("device db path {} not found".format(path))
        else:
            return default
Exemplo n.º 13
0
 def load(self):
     try:
         data = pyon.load_file(self.filename)
     except FileNotFoundError:
         logger.info("State database '%s' not found, using defaults",
                     self.filename)
         return
     # The state of one object may depend on the state of another,
     # e.g. the display state may create docks that are referenced in
     # the area state.
     # To help address this problem, state is restored in the opposite
     # order as the stateful objects are registered.
     for name, obj in reversed(list(self.stateful_objects.items())):
         state = data.get(name, None)
         if state is not None:
             try:
                 _restore_state(obj, state)
             except:
                 logger.warning("Failed to restore state for object '%s'",
                                name, exc_info=True)
Exemplo n.º 14
0
 def load(self):
     try:
         data = pyon.load_file(self.filename)
     except FileNotFoundError:
         logger.info("State database '%s' not found, using defaults",
                     self.filename)
         return
     # The state of one object may depend on the state of another,
     # e.g. the display state may create docks that are referenced in
     # the area state.
     # To help address this problem, state is restored in the opposite
     # order as the stateful objects are registered.
     for name, obj in reversed(list(self.stateful_objects.items())):
         state = data.get(name, None)
         if state is not None:
             try:
                 _restore_state(obj, state)
             except:
                 logger.warning("Failed to restore state for object '%s'",
                                name,
                                exc_info=True)
Exemplo n.º 15
0
    def calcNewDACvaluesFromFreqDiff(self, freq_diff, corrFactor=1):
        """Calculate new DAC values, based on the stretch qubit frequency difference to the setpoint"""
        # least significant bits in mV output
        fDAClsb = self.mVDAC_per_DACvalue
        # VERR = 200*cDAC + fDAC - 202*DIFF_SIG
        cDAClsb = 200 * fDAClsb
        
        VERR_diff = freq_diff / self.kHz_per_mVerr / 1e3
        VERR_corr = VERR_diff * corrFactor

        if abs(VERR_corr) > 10*cDAClsb:
            change_cDAC = - int(round(VERR_corr / cDAClsb))
            change_fDAC = 0
        else:
            change_cDAC = 0
            change_fDAC = - int(round(VERR_corr / fDAClsb))
        
        try:
            oldDacValues = pyon.load_file(self.fname)
            #old_cDAC = self.get_dataset("BField_stabiliser.cDAC")
            #old_fDAC = self.get_dataset("BField_stabiliser.fDAC")
        except FileNotFoundError:
            print('Error: could not find file. Using default values')
            oldDacValues = {'cDAC':54710,'fDAC':33354}
        old_cDAC = oldDacValues['cDAC']
        old_fDAC = oldDacValues['fDAC']
        
        new_cDAC = old_cDAC + change_cDAC
        new_fDAC = old_fDAC + change_fDAC
        
        # when fDAC out of range, change coarse DAC
        if (new_fDAC > self.maxDACvalue or new_fDAC < 0):
            new_cDAC += (new_fDAC-30000)/200
            new_fDAC = 30000
        
        return [new_cDAC, new_fDAC]
Exemplo n.º 16
0
 def __init__(self, filename):
     self.filename = filename
     self.data = Notifier(pyon.load_file(self.filename))
     self.hooks = []
Exemplo n.º 17
0
	def __init__(self, fname: str):
		self.db = pyon.load_file(fname) 
Exemplo n.º 18
0
 def __init__(self, backing_file):
     self.backing_file = backing_file
     self.data = Notifier(pyon.load_file(self.backing_file))
Exemplo n.º 19
0
 def __init__(self, backing_file):
     self.backing_file = backing_file
     self.data = Notifier(pyon.load_file(self.backing_file))