.. api_interface: Getting data from pymepix api interface ======================================= First, pymepix should be installed. Then, a queue needs to be created to hold the data from the timepix camera, as well as a SPIDRController which will receive the data. .. code-block:: python from multiprocessing import Queue from pymepix.SPIDR.spidrcontroller import SPIDRController from pymepix.timepixdevice import TimepixDevice from pymepix.processing.acquisition import CentroidPipeline # Create a queue for the data data_queue = Queue() # A SPIDRController is needed to receive data from the network for x in SPIDRController(): # Create TimepixDevice, which will record data and put it in the provided queue timepixDevice = TimepixDevice(x, data_queue, CentroidPipeline) timepixDevice.start() In this example we will assume that only a single camera is being used. Now that it is possible to store data, it still needs to be processed. .. code-block:: python # Example method for data processing. Your logic goes here def onData(message_type: MessageType, event): print(f"Message Type: {MessageType(message_type).name}") print(f"Data: {event}\n") # Example method for data collection. Needs to be started as a thread def data_thread(): while True: # This will block execution of this thread until data arrives value = data_queue.get() if value is None: break # If there is data, call our example method data_type, data = value onData(data_type, data) Now that methods for data processing have been defined they should be executed as a new thread: .. code-block:: python import threading # Create and start thread for data processing data_thread = threading.Thread(target=data_thread) data_thread.daemon = True data_thread.start() Lastly, the TimepixDevice needs to start recording data .. code-block:: python timepixDevice.start_recording("TEST.raw") input("Press Enter to stop...") print("Stopping") Alternatively, it is also possible to use the provided PymepixConnection class from the pymepix module: .. code-block:: python import pymepix from pymepix.processing.acquisition import CentroidPipeline pymepixConnection = pymepix.PymepixConnection(pipeline_class=CentroidPipeline) # "onData" method still needs to be definded, as shown above pymepixConnection.dataCallback = onData pymepixConnection.start() pymepixConnection.start_recording("TEST.raw")