Esempio n. 1
0
	def resync_psrc(self):  # Quicker version than the general purpose implementation
		result = ParameterSource.get_empty_resync_result()
		for psrc in self._psrc_list:
			result = _combine_resync_result(result, psrc.resync_psrc())
		psrc_max_old = self._psrc_max
		self._psrc_max_list = lmap(lambda p: p.get_parameter_len(), self._psrc_list)
		self._psrc_max = self._init_psrc_max()
		return (result[0], result[1], psrc_max_old != self._psrc_max)
Esempio n. 2
0
	def resync(self, force=False):
		source_hash = self._psrc.get_psrc_hash()
		do_resync = (source_hash != self._psrc_hash) or self._psrc.get_resync_request() or force
		# Do not overwrite resync results - eg. from external or init trigger
		if (self._resync_state == ParameterSource.get_empty_resync_result()) and do_resync:
			activity = Activity('Syncronizing parameter information')
			t_start = time.time()
			try:
				self._resync_state = self._resync()
			except Exception:
				raise ParameterError('Unable to resync parameters!')
			self._psrc_hash = self._psrc.get_psrc_hash()
			activity.finish()
			self._log.log(logging.INFO, 'Finished resync of parameter source (%s)',
				str_time_short(time.time() - t_start))
		result = self._resync_state
		self._resync_state = ParameterSource.get_empty_resync_result()
		return result
Esempio n. 3
0
 def resync_psrc(
         self):  # Quicker version than the general purpose implementation
     result = ParameterSource.get_empty_resync_result()
     for psrc in self._psrc_list:
         result = _combine_resync_result(result, psrc.resync_psrc())
     psrc_max_old = self._psrc_max
     self._psrc_max_list = lmap(lambda p: p.get_parameter_len(),
                                self._psrc_list)
     self._psrc_max = self._init_psrc_max()
     return (result[0], result[1], psrc_max_old != self._psrc_max)
Esempio n. 4
0
	def resync_psrc(self):
		(result_redo, result_disable, _) = ParameterSource.get_empty_resync_result()
		(psrc_redo, psrc_disable, psrc_size_change) = self._psrc.resync_psrc()
		self._psp_field = self._init_psp_field()
		for pnum, psp_info in enumerate(self._psp_field):
			psrc_pnum, _ = psp_info  # ignore output_idx
			if psrc_pnum in psrc_redo:
				result_redo.add(pnum)
			if psrc_pnum in psrc_disable:
				result_disable.add(pnum)
		return (result_redo, result_disable, psrc_size_change)
Esempio n. 5
0
	def _resync(self):  # This function is _VERY_ time critical!
		tmp = self._psrc_raw.resync_psrc()  # First ask about psrc changes
		(result_redo, result_disable, size_change) = (set(tmp[0]), set(tmp[1]), tmp[2])
		psrc_hash_new = self._psrc_raw.get_psrc_hash()
		psrc_hash_changed = self._psrc_hash_stored != psrc_hash_new
		self._psrc_hash_stored = psrc_hash_new
		if not (result_redo or result_disable or size_change or psrc_hash_changed):
			return ParameterSource.get_empty_resync_result()

		ps_old = ParameterSource.create_instance('GCDumpParameterSource', self._path_params)
		pa_old = ParameterAdapter(None, ps_old)
		pa_new = ParameterAdapter(None, self._psrc_raw)
		return self._resync_adapter(pa_old, pa_new, result_redo, result_disable, size_change)
Esempio n. 6
0
	def resync_psrc(self):
		(result_redo, result_disable, _) = ParameterSource.get_empty_resync_result()
		# size change is irrelevant if outside of range
		(psrc_redo, psrc_disable, _) = self._psrc.resync_psrc()

		def _translate(source, target):
			for pnum in source:
				if self._pos_start <= pnum <= self._pos_end:
					target.add(pnum - self._pos_start)
		_translate(psrc_redo, result_redo)
		_translate(psrc_disable, result_disable)
		pos_end_old = self._pos_end
		self._pos_end = self._get_pos_end()
		return (result_redo, result_disable, pos_end_old != self._pos_end)
Esempio n. 7
0
	def resync_psrc(self):
		psrc_max_old = self._psrc_max
		# Perform resync of subsources
		psrc_resync_list = lmap(lambda p: p.resync_psrc(), self._psrc_list)
		# Update max for _translate_pnum
		self._psrc_max_list = lmap(lambda p: p.get_parameter_len(), self._psrc_list)
		self._psrc_max = self._init_psrc_max()
		# translate affected pnums from subsources
		(result_redo, result_disable, _) = ParameterSource.get_empty_resync_result()
		for (psrc_idx, psrc_resync) in enumerate(psrc_resync_list):
			(psrc_redo, psrc_disable, _) = psrc_resync
			for pnum in psrc_redo:
				result_redo.update(self._translate_pnum(psrc_idx, pnum))
			for pnum in psrc_disable:
				result_disable.update(self._translate_pnum(psrc_idx, pnum))
		return (result_redo, result_disable, psrc_max_old != self._psrc_max)
Esempio n. 8
0
    def resync_psrc(self):
        (result_redo, result_disable,
         _) = ParameterSource.get_empty_resync_result()
        # size change is irrelevant if outside of range
        (psrc_redo, psrc_disable, _) = self._psrc.resync_psrc()

        def _translate(source, target):
            for pnum in source:
                if self._pos_start <= pnum <= self._pos_end:
                    target.add(pnum - self._pos_start)

        _translate(psrc_redo, result_redo)
        _translate(psrc_disable, result_disable)
        pos_end_old = self._pos_end
        self._pos_end = self._get_pos_end()
        return (result_redo, result_disable, pos_end_old != self._pos_end)
Esempio n. 9
0
 def resync_psrc(self):
     psrc_max_old = self._psrc_max
     # Perform resync of subsources
     psrc_resync_list = lmap(lambda p: p.resync_psrc(), self._psrc_list)
     # Update max for _translate_pnum
     self._psrc_max_list = lmap(lambda p: p.get_parameter_len(),
                                self._psrc_list)
     self._psrc_max = self._init_psrc_max()
     # translate affected pnums from subsources
     (result_redo, result_disable,
      _) = ParameterSource.get_empty_resync_result()
     for (psrc_idx, psrc_resync) in enumerate(psrc_resync_list):
         (psrc_redo, psrc_disable, _) = psrc_resync
         for pnum in psrc_redo:
             result_redo.update(self._translate_pnum(psrc_idx, pnum))
         for pnum in psrc_disable:
             result_disable.update(self._translate_pnum(psrc_idx, pnum))
     return (result_redo, result_disable, psrc_max_old != self._psrc_max)
Esempio n. 10
0
	def __init__(self, config, source):
		ParameterAdapter.__init__(self, config, source)
		self._psrc_hash = source.get_psrc_hash()
		self._resync_state = ParameterSource.get_empty_resync_result()
Esempio n. 11
0
	def resync(self, force=False):
		result = ResyncParameterAdapter.resync(self, force)
		if result not in (None, ParameterSource.get_empty_resync_result()):
			self._can_submit_map = {}  # invalidate cache on changes
		return result