示例#1
0
    def _handleNativeEvent(self, *args, **kwargs):
        """
        _handleEvent is used by devices that signal new events by using an event driven
        callback approach.
        One args is required, the device event to be handled, "event"
        """
        loggedTime = int(Computer.currentUsec())

        event = None
        if len(args) > 0:
            event = args[0]

        # do any manipulation to the native event object here before putting it in the devices
        # circular buffer. Remember to keep work done in the callback to a minimum. For example,
        # the conversion to a native ioHub event is done in the _getIOHubEventObject(event,device_instance_code)
        # method, so does not need to be done here.
        #
        # ......
        #

        if 1:
            return 'EYETRACKER_ERROR', '_handleNativeEvent', 'Default _handleNativeEvent callback Logic being Used. This must be implemented on a per eye tracker basis.'

        EyeTracker.lastCallbackTime = loggedTime

        # append the native event to the deque as a tuple of (loggedTime, event)
        # This can be unpacked in the _getIOHubEventObject and the current_time
        # used as the logged_time field of the ioHub DeviceEvent object.
        #
        self.I_nativeEventBuffer.append((loggedTime, event))
示例#2
0
    def _handleNativeEvent(self, *args, **kwargs):
        """
        _handleEvent is used by devices that signal new events by using an event driven
        callback approach.
        One args is required, the device event to be handled, "event"
        """
        loggedTime = int(Computer.currentUsec())

        event = None
        if len(args) > 0:
            event = args[0]

        # do any manipulation to the native event object here before putting it in the devices
        # circular buffer. Remember to keep work done in the callback to a minimum. For example,
        # the conversion to a native ioHub event is done in the _getIOHubEventObject(event,device_instance_code)
        # method, so does not need to be done here.
        #
        # ......
        #

        if 1:
            return (
                "EYETRACKER_ERROR",
                "_handleNativeEvent",
                "Default _handleNativeEvent callback Logic being Used. This must be implemented on a per eye tracker basis.",
            )

        EyeTracker.lastCallbackTime = loggedTime

        # append the native event to the deque as a tuple of (loggedTime, event)
        # This can be unpacked in the _getIOHubEventObject and the current_time
        # used as the logged_time field of the ioHub DeviceEvent object.
        #
        self.I_nativeEventBuffer.append((loggedTime, event))
示例#3
0
    def _poll(self):
        """
        For use in systems where a polling model is used to check for new events and samples.
        If your eye tracker supports an event based call-back approach, use _handleEvent(...) instead
        of _poll and remove the periodic timer from the ioHub_config.yaml file settings.
        """
        loggedTime = int(Computer.currentUsec())
        currentHostTime = self.trackerTime()
        ioHub_time_offset = loggedTime - currentHostTime

        if 1:
            return 'EYETRACKER_ERROR', '_poll', 'Default Poll Logic being Used. This must be implemented on a per eye tracker basis.'

        #get native events queued up
        noMoreDeviceEvents = True
        while 1:
            # get each native device event (this will be eye tracker specific)
            #
            # ....

            # determine the event type and map it to one of the ioHub eye tracker event types
            # found in ioHub.devices.eyeTrackerInterface.eye_events.py
            #
            # ......

            if noMoreDeviceEvents:
                break

            ioHubEvent = list()
            # put the ioHub eye tracker event IN ORDERED LIST FORM in devices buffer for pickup by the ioHub.

            self.I_nativeEventBuffer.append(ioHubEvent)

        EyeTracker.lastPollTime = loggedTime
示例#4
0
    def _poll(self):
        """
        For use in systems where a polling model is used to check for new events and samples.
        If your eye tracker supports an event based call-back approach, use _handleEvent(...) instead
        of _poll and remove the periodic timer from the ioHub_config.yaml file settings.
        """
        loggedTime=int(Computer.currentUsec())
        currentHostTime = self.trackerTime()
        ioHub_time_offset= loggedTime-currentHostTime

        if 1:
            return 'EYETRACKER_ERROR','_poll','Default Poll Logic being Used. This must be implemented on a per eye tracker basis.'

        #get native events queued up
        noMoreDeviceEvents=True
        while 1:    
            # get each native device event (this will be eye tracker specific)
            #
            # ....
            
            # determine the event type and map it to one of the ioHub eye tracker event types
            # found in ioHub.devices.eyeTrackerInterface.eye_events.py
            #
            # ......

            if noMoreDeviceEvents:
                break

            ioHubEvent = list()
            # put the ioHub eye tracker event IN ORDERED LIST FORM in devices buffer for pickup by the ioHub.

            self.I_nativeEventBuffer.append(ioHubEvent)

        EyeTracker.lastPollTime=loggedTime