summaryrefslogtreecommitdiffstats
path: root/tests/timeout.py
blob: eede1e727fe68412608f5c5ae3b3d19d1e7d9ed6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import time
import argparse
import PyTango


def grab(camera, timeout, do_trigger):
    camera.timeout = timeout
    camera.trigger_source = 1

    try:
        camera.Start()
    except:
        camera.Stop()
        camera.Start()

    start = time.time()

    try:
        if do_trigger:
            camera.Trigger()

        frame = camera.image
        end = time.time()
        print("Success after {} s".format(end -start))
    except PyTango.DevFailed:
        end = time.time()
        print("Timeout after {} s".format(end - start))

    camera.Stop()


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--device', '-d', type=str, required=True,
                        help="TANGO device path")

    args = parser.parse_args()

    camera = PyTango.DeviceProxy(args.device)
    grab(camera, 100000, False)
    grab(camera, 100000, True)
    grab(camera, 300000, False)
    grab(camera, 300000, True)