Beispiel #1
0
    def unsubscribe_from(self, subscription_type, callback=None):
        '''Unsubscribes from data for the eye tracker.

        See @ref find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.
        You can unsubscribe from @ref EYETRACKER_EXTERNAL_SIGNAL, @ref EYETRACKER_EYE_IMAGES, @ref EYETRACKER_GAZE_DATA,
        @ref EYETRACKER_HMD_GAZE_DATA, @ref EYETRACKER_USER_POSITION_GUIDE,
        @ref EYETRACKER_NOTIFICATION_CONNECTION_LOST, @ref EYETRACKER_NOTIFICATION_CONNECTION_RESTORED,
        @ref EYETRACKER_NOTIFICATION_CALIBRATION_MODE_ENTERED, @ref EYETRACKER_NOTIFICATION_CALIBRATION_MODE_LEFT,
        @ref EYETRACKER_NOTIFICATION_CALIBRATION_CHANGED, @ref EYETRACKER_NOTIFICATION_TRACK_BOX_CHANGED,
        @ref EYETRACKER_NOTIFICATION_DISPLAY_AREA_CHANGED, @ref EYETRACKER_NOTIFICATION_GAZE_OUTPUT_FREQUENCY_CHANGED,
        @ref EYETRACKER_NOTIFICATION_EYE_TRACKING_MODE_CHANGED,
        @ref EYETRACKER_NOTIFICATION_DEVICE_FAULTS, @ref EYETRACKER_NOTIFICATION_DEVICE_WARNINGS,
        @ref EYETRACKER_TIME_SYNCHRONIZATION_DATA or @ref EYETRACKER_STREAM_ERRORS.
        <CodeExample>gaze_data.py</CodeExample>
        Args:
        subscription_type: Type of data to unsubscribe from.
        callback: Callback sent to subscribe_to or None to unsubscribe all subscriptions of this type.
        '''
        global _available_notification_subscriptions
        global _EYETRACKER_NOTIFICATIONS_BASE

        # Special handling of notification subscribtions.
        if subscription_type in _available_notification_subscriptions.keys():
            with self.__notification_subscription_lock:
                if subscription_type in self.__notification_subscriptions:
                    if callback in self.__notification_subscriptions[
                            subscription_type]:
                        del self.__notification_subscriptions[
                            subscription_type][callback]
                    if callback is None or len(
                            self.__notification_subscriptions[
                                subscription_type]) == 0:
                        del self.__notification_subscriptions[
                            subscription_type]
                    if len(self.__notification_subscriptions) == 0:
                        self.unsubscribe_from(_EYETRACKER_NOTIFICATIONS, None)
        else:
            if subscription_type not in _subscription_types:
                _on_error_raise_exception(_invalid_parameter)
            with self.__subscription_lock:
                if subscription_type in self.__subscriptions:
                    if callback in self.__subscriptions[subscription_type]:
                        del self.__subscriptions[subscription_type][callback]
                    if callback is None or len(
                            self.__subscriptions[subscription_type]) == 0:
                        del self.__subscriptions[subscription_type]
                        interop.unsubscribe_from(
                            _subscription_types[subscription_type]
                            ["type_index"], self, self.__core_eyetracker)
Beispiel #2
0
 def __del__(self):
     with self.__subscription_lock:
         for subscription_type in self.__subscriptions.keys():
             interop.unsubscribe_from(subscription_type, self,
                                      self.__core_eyetracker)
Beispiel #3
0
def _logging_unsubscribe():
    interop.unsubscribe_from(0, None, 0)