def setConnectionState(self, enable):
        """
        setConnectionState is used to connect ( setConnectionState(True) ) 
        or disable ( setConnectionState(False) ) the connection of the ioHub 
        to the eyetracker hardware.
        
        Note that a connection to the eye tracking hardware is automatically
        openned when the ioHub Server process is started. So there is no need to
        call this method at the start of your experiment. Doing so will have no
        effect on the connection state.
        
        When an eye tracker device is connected to the ioHub it is **not** also recording
        eye data and sending the data to the ioHub Server. To start actual eye data
        recording, use the setRecordingState(bool) or device type independent
        enableEventReporting(bool) method to start and stop eye data recording.

        Args:
            enable (bool): True = enable the connection, False = disable the connection.

        Return:
            bool: indicates the current connection state to the eye tracking hardware.
            
        """
        try:
            if isinstance(enable, bool):
                if enable is True and not self.isConnected():
                    self._eyegaze_control = pEyeGaze.initializeEyeGazeDevice(
                        self._display_device, self.getConfiguration())
                    if self._eyegaze_control is None:
                        print2err(
                            "Could not connect to EyeGaze. Exiting app..")
                        sys.exit(0)
                    if self._eyegaze_control:
                        return True
                    return False
                elif enable is False and self.isConnected():
                    result = pEyeGaze.EgExit(byref(self._eyegaze_control))
                    self._eyegaze_control = None
                    return False
            else:
                return createErrorResult(
                    "INVALID_METHOD_ARGUMENT_VALUE",
                    error_message=
                    "The enable arguement value provided is not recognized",
                    method="EyeTracker.setConnectionState",
                    arguement='enable',
                    value=enable)
        except Exception, e:
            return createErrorResult(
                "IOHUB_DEVICE_EXCEPTION",
                error_message=
                "An unhandled exception occurred on the ioHub Server Process.",
                method="EyeTracker.setConnectionState",
                arguement='enable',
                value=enable,
                error=e)
Example #2
0
    def setConnectionState(self, enable):
        """setConnectionState is used to connect ( setConnectionState(True) )
        or disable ( setConnectionState(False) ) the connection of the ioHub to
        the eyetracker hardware.

        Note that a connection to the eye tracking hardware is automatically
        openned when the ioHub Server process is started. So there is no need to
        call this method at the start of your experiment. Doing so will have no
        effect on the connection state.

        When an eye tracker device is connected to the ioHub it is **not** also recording
        eye data and sending the data to the ioHub Server. To start actual eye data
        recording, use the setRecordingState(bool) or device type independent
        enableEventReporting(bool) method to start and stop eye data recording.

        Args:
            enable (bool): True = enable the connection, False = disable the connection.

        Return:
            bool: indicates the current connection state to the eye tracking hardware.

        """
        try:
            if isinstance(enable, bool):
                if enable is True and not self.isConnected():
                    self._eyegaze_control = pEyeGaze.initializeEyeGazeDevice(
                        self._display_device, self.getConfiguration())
                    if self._eyegaze_control is None:
                        print2err(
                            'Could not connect to EyeGaze. Exiting app..')
                        sys.exit(0)
                    if self._eyegaze_control:
                        return True
                    return False
                elif enable is False and self.isConnected():
                    result = pEyeGaze.EgExit(byref(self._eyegaze_control))
                    self._eyegaze_control = None
                    return False
            else:
                return print2err(
                    'INVALID_METHOD_ARGUMENT_VALUE. ',
                    'EyeTracker.setConnectionState: ',
                    enable)
        except Exception as e:
            # ("IOHUB_DEVICE_EXCEPTION",error_message="An unhandled exception occurred on the ioHub Server Process.",method="EyeTracker.setConnectionState",arguement='enable', value=enable, error=e)
            return printExceptionDetailsToStdErr()
Example #3
0
 def setConnectionState(self,enable):
     """
     """
     try:
         if isinstance(enable,bool):
             if enable is True and not self.isConnected():
                 self._eyegaze_control=pEyeGaze.initializeEyeGazeDevice(self._display_device, self.getConfiguration())           
                 if self._eyegaze_control is None:
                     ioHub.print2err("Could not connect to EyeGaze. Exiting app..")
                     sys.exit(0)                                        
                 if self._eyegaze_control:
                     return True
                 return False
             elif enable is False and self.isConnected():
                 result=pEyeGaze.EgExit(byref(self._eyegaze_control))
                 self._eyegaze_control=None
                 return False
         else:
             return createErrorResult("INVALID_METHOD_ARGUMENT_VALUE",error_message="The enable arguement value provided is not recognized",method="EyeTracker.setConnectionState",arguement='enable', value=enable)            
     except Exception,e:
             return createErrorResult("IOHUB_DEVICE_EXCEPTION",error_message="An unhandled exception occurred on the ioHub Server Process.",method="EyeTracker.setConnectionState",arguement='enable', value=enable, error=e)