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_TRACK_BOX_CHANGED,
22 tr.EYETRACKER_NOTIFICATION_DISPLAY_AREA_CHANGED,
23 tr.EYETRACKER_NOTIFICATION_GAZE_OUTPUT_FREQUENCY_CHANGED,
24 tr.EYETRACKER_NOTIFICATION_EYE_TRACKING_MODE_CHANGED,
25 tr.EYETRACKER_NOTIFICATION_DEVICE_FAULTS,
26 tr.EYETRACKER_NOTIFICATION_DEVICE_WARNINGS)
29 for notification
in all_notifications:
30 eyetracker.subscribe_to(notification,
31 lambda x, notification=notification: notification_callback(notification, x))
32 print(
"Subscribed to {0} for eye tracker with serial number {1}.".
33 format(notification, eyetracker.serial_number))
36 calibration = tr.ScreenBasedCalibration(eyetracker)
38 calibration.enter_calibration_mode()
40 calibration.leave_calibration_mode()
43 for notification
in all_notifications:
44 eyetracker.unsubscribe_from(notification)
45 print(
"Unsubscribed from {0}.".format(notification))