.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "11_demos\itom\basics\demo_timerExample.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_11_demos_itom_basics_demo_timerExample.py: Timer =========== This script creates an instance of a ``DummyGrabber`` and implements a timer with an interval of ``1000ms``. Everytime, the interval is expired the method ``imageAcquisition`` is called. It acquires a new image an appends it to the global list ``myImages``. To stop the timer, call the method ``cancel``. Additionally, the timer is automatically interrupted after ``10`` iterations. .. GENERATED FROM PYTHON SOURCE LINES 14-18 .. code-block:: default from itom import timer from itom import dataIO from itom import dataObject .. GENERATED FROM PYTHON SOURCE LINES 20-21 Function for the image acquisition. .. GENERATED FROM PYTHON SOURCE LINES 21-38 .. code-block:: default def imageAcquisition(): global iters global t global cam global myImages print("acquire next image") cam.acquire() d = dataObject() cam.getVal(d) globals()["myImages"].append(d.copy()) iters += 1 if iters >= 10: t.stop() .. GENERATED FROM PYTHON SOURCE LINES 39-40 Call this method (e.g. by your gui) to stop the timer. .. GENERATED FROM PYTHON SOURCE LINES 40-48 .. code-block:: default def cancel(): global t global cam t.stop() cam.stopDevice() .. GENERATED FROM PYTHON SOURCE LINES 49-50 Define a ``DummyGrabber`` camera and timer for a timed acquisition. .. GENERATED FROM PYTHON SOURCE LINES 50-57 .. code-block:: default cam = dataIO("DummyGrabber") myImages = [] iters = 0 cam.startDevice() t = timer(1000, imageAcquisition) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.015 seconds) .. _sphx_glr_download_11_demos_itom_basics_demo_timerExample.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_timerExample.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_timerExample.ipynb `