Calculate PI output value for given reference input and feedback

def controler_output(self, current_value):
        """
        Calculate PI output value for given reference input and feedback
        """

        set_point = self.settings['set_point']
        Kp = self.settings['gains']['proportional']
        Ki = self.settings['gains']['integral']
        output_range = self.settings['output_range']
        time_step = self.settings['time_step']

        error_new = set_point - current_value
        print(('PD- error:\t', error_new, Ki, Kp, time_step))
        #proportional action
        self.u_P = Kp * error_new * time_step
        print(('PD- self.u_P:\t', self.u_P, self.u_I))

        #integral action
        self.u_I += Kp * Ki * (error_new + self.error) / 2.0 * time_step

        self.error = error_new

        print(('PD- self.u_P:\t', self.u_P, self.u_I))

        # anti-windup
        if self.u_P + self.u_I > output_range['max']:
            self.u_I = output_range['max']-self.u_P
        if self.u_P + self.u_I < output_range['min']:
            self.u_I = output_range['min']-self.u_P


        output = self.u_P + self.u_I
        print(('PD- output:\t', output))
        return output