1 def execute(eyetracker):
2 if eyetracker
is not None:
3 notifications(eyetracker)
7 import tobii_research
as tr
10 def notification_callback(notification, data):
11 print(
"Notification {0} received at time stamp {1}.".format(notification, data.system_time_stamp))
14 def notifications(eyetracker):
16 (tr.EYETRACKER_NOTIFICATION_CONNECTION_LOST,
17 tr.EYETRACKER_NOTIFICATION_CONNECTION_RESTORED,
18 tr.EYETRACKER_NOTIFICATION_CALIBRATION_MODE_ENTERED,
19 tr.EYETRACKER_NOTIFICATION_CALIBRATION_MODE_LEFT,
20 tr.EYETRACKER_NOTIFICATION_CALIBRATION_CHANGED,
21 tr.EYETRACKER_NOTIFICATION_DISPLAY_AREA_CHANGED,
22 tr.EYETRACKER_NOTIFICATION_GAZE_OUTPUT_FREQUENCY_CHANGED,
23 tr.EYETRACKER_NOTIFICATION_EYE_TRACKING_MODE_CHANGED,
24 tr.EYETRACKER_NOTIFICATION_DEVICE_FAULTS,
25 tr.EYETRACKER_NOTIFICATION_DEVICE_WARNINGS,
26 tr.EYETRACKER_NOTIFICATION_STREAM_BUFFER_OVERFLOW,
30 for notification
in all_notifications:
31 eyetracker.subscribe_to(notification,
32 lambda x, notification=notification: notification_callback(notification, x))
33 print(
"Subscribed to {0} for eye tracker with serial number {1}.".
34 format(notification, eyetracker.serial_number))
37 calibration = tr.ScreenBasedCalibration(eyetracker)
39 calibration.enter_calibration_mode()
41 calibration.leave_calibration_mode()
44 for notification
in all_notifications:
45 eyetracker.unsubscribe_from(notification)
46 print(
"Unsubscribed from {0}.".format(notification))