# Process control¶

## Scanning¶

scan() is used to scan a device parameter and start a feedback action. For instance, to set 10 motor positions between 5 and 12 millimeter and acquire the flow rate of a pump could be written like:

from concert.processes import scan

# Assume motor and pump are already defined

def get_flow_rate():
return pump.flow_rate

x, y = scan(motor['position'], get_flow_rate,
5*q.mm, 12*q.mm, 10).result()


As you can see scan() always yields a future that needs to be resolved when you need the result.

ascan() and dscan() are used to scan multiple parameters in a similar way as SPEC:

from concert.quantities import q
from concert.processes import ascan

def do_something(parameters):
for each parameter in parameters:
print(parameter)

ascan([(motor1['position'], 0 * q.mm, 25 * q.mm),
(motor2['position'], -2 * q.cm, 4 * q.cm)],
n_intervals=10, handler=do_something)


## Focusing¶

To adjust the focal plane of a camera, you use focus() like this:

from concert.processes import focus
from concert.cameras.uca import Camera
from concert.motors.dummy import LinearMotor

motor = LinearMotor()
camera = Camera('mock')
focus(camera, motor)