#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Sep  8 13:49:51 2023

@author: mas8128
"""

import zmq

# Initialize a ZeroMQ context and socket
context = zmq.Context()
socket = context.socket(zmq.PULL)
socket.bind("tcp://127.0.0.1:50020")  # Pupil Remote default address

while True:
    # Receive gaze data from Pupil Capture
    gaze_data = socket.recv_json()

    # Check if the received data contains pupil diameter information
    if 'diameter_3d' in gaze_data:
        pupil_diameter = gaze_data['diameter_3d']  # Accessing 3D diameter, you can also use 'diameter_2d'
        
        # Process the pupil diameter data as needed
        print(f"Pupil Diameter: {pupil_diameter} mm")
        
    # Add your other processing logic here for other gaze data, if needed