exopy_hqc_legacy/tasks/tasks/instr/dc_tasks.py
def smooth_set(self, target_value, setter, current_value):
        """ Smoothly set the current.

        target_value : float
            Current to reach.

        setter : callable
            Function to set the current, should take as single argument the
            value.

        """
        if target_value is not None:
            value = target_value
        else:
            value = self.format_and_eval_string(self.target_value)

        if self.safe_max and self.safe_max < abs(value):
            msg = 'Requested current {} exceeds safe max : {}'
            raise ValueError(msg.format(value, self.safe_max))

        last_value = current_value

        if abs(last_value - value) < 1e-12:
            self.write_in_database('current', value)
            return

        elif self.back_step == 0:
            self.write_in_database('current', value)
            setter(value)
            return

        else:
            if (value - last_value)/self.back_step > 0:
                step = self.back_step
            else:
                step = -self.back_step

        if abs(value-last_value) > abs(step):
            while not self.root.should_stop.is_set():
                # Avoid the accumulation of rounding errors
                last_value = round(last_value + step, 9)
                setter(last_value)
                if abs(value-last_value) > abs(step):
                    time.sleep(self.delay)
                else:
                    break

        if not self.root.should_stop.is_set():
            setter(value)
            self.write_in_database('current', value)
            return

        self.write_in_database('current', last_value)
 Smoothly set the current.

        target_value : float
            Current to reach.

        setter : callable
            Function to set the current, should take as single argument the
            value.

        
Smoothly set the current.
target_value : float
Current to reach.

setter : callable
Function to set the current, should take as single argument the
value.
Smoothly set the current . target_value : float Current to reach . setter : callable Function to set the current should take as single argument the value .
def smooth_set(self, target_value, setter, current_value):
        if target_value is not None:
            value = target_value
        else:
            value = self.format_and_eval_string(self.target_value)
        if self.safe_max and self.safe_max < abs(value):
            msg = 'Requested current {} exceeds safe max : {}'
            raise ValueError(msg.format(value, self.safe_max))
        last_value = current_value
        if abs(last_value - value) < 1e-12:
            self.write_in_database('current', value)
            return
        elif self.back_step == 0:
            self.write_in_database('current', value)
            setter(value)
            return
        else:
            if (value - last_value)/self.back_step > 0:
                step = self.back_step
            else:
                step = -self.back_step
        if abs(value-last_value) > abs(step):
            while not self.root.should_stop.is_set():
                last_value = round(last_value + step, 9)
                setter(last_value)
                if abs(value-last_value) > abs(step):
                    time.sleep(self.delay)
                else:
                    break
        if not self.root.should_stop.is_set():
            setter(value)
            self.write_in_database('current', value)
            return
        self.write_in_database('current', last_value)
def smooth_set ( self , target_value , setter , current_value ) : if target_value is not None : value = target_value else : value = self . format_and_eval_string ( self . target_value ) if self . safe_max and self . safe_max < abs ( value ) : msg = 'Requested current {} exceeds safe max : {}' raise ValueError ( msg . format ( value , self . safe_max ) ) last_value = current_value if abs ( last_value - value ) < 1e-12 : self . write_in_database ( 'current' , value ) return elif self . back_step == 0 : self . write_in_database ( 'current' , value ) setter ( value ) return else : if ( value - last_value ) / self . back_step > 0 : step = self . back_step else : step = - self . back_step if abs ( value - last_value ) > abs ( step ) : while not self . root . should_stop . is_set ( ) : last_value = round ( last_value + step , 9 ) setter ( last_value ) if abs ( value - last_value ) > abs ( step ) : time . sleep ( self . delay ) else : break if not self . root . should_stop . is_set ( ) : setter ( value ) self . write_in_database ( 'current' , value ) return self . write_in_database ( 'current' , last_value )
Smoothly set the current.
Smoothly set the current .
""" Smoothly set the current.

        target_value : float
            Current to reach.

        setter : callable
            Function to set the current, should take as single argument the
            value.

        """ # Avoid the accumulation of rounding errors
self
target_value
setter
current_value