Best Python code snippet using responses
eyetracker.py
Source:eyetracker.py
1#2# Generated on: 2011-01-25T13:53:55.389+01:003#4from tobii.eye_tracking_io.basic import BasicEyetracker5from tobii.eye_tracking_io.utils.events import Events6from tobii.eye_tracking_io._native import tetio7from tobii.eye_tracking_io.types import *8from tobii.eye_tracking_io import converters9from tobii.eye_tracking_io.converters import ParamStackReader10from tobii.eye_tracking_io.xds import Converter11#from zope.interface.adapter import _convert_None_to_Interface12# Helper Types13class CalibrationStartedEventArgs:14 def __init__(self):15 pass16class CalibrationStoppedEventArgs:17 def __init__(self):18 pass19class TrackBoxChangedEventArgs:20 def __init__(self):21 pass22 23class AuthorizeChallenge(object):24 def __init__(self): 25 """26 The realm id for this challenge27 """28 self.RealmId = long()29 """30 The encryption algorithm for this challenge31 """32 self.Algorithm = long()33 """34 The challenge data35 """36 self.ChallengeData = Blob()37class Configuration(object):38 def __init__(self): 39 self.Root = Node()40class ConfigurationKey(object):41 def __init__(self): 42 self.Key = Node()43class TrackBox(object):44 def __init__(self): 45 self.Point1 = Point3D()46 self.Point2 = Point3D()47 self.Point3 = Point3D()48 self.Point4 = Point3D()49 self.Point5 = Point3D()50 self.Point6 = Point3D()51 self.Point7 = Point3D()52 self.Point8 = Point3D()53class XConfiguration(object):54 def __init__(self): 55 self.UpperLeft = Point3D()56 self.UpperRight = Point3D()57 self.LowerLeft = Point3D()58class UnitInfo(object):59 def __init__(self): 60 self.SerialNumber = str()61 self.Model = str()62 self.Generation = str()63 self.FirmwareVersion = str()64class PayperuseInfo(object):65 def __init__(self): 66 """67 Whether PayPerUse is enabled for this eyetracker.68 """69 self.Enabled = bool()70 """71 The realm to authorize if PayPerUse is enabled.72 """73 self.Realm = long()74 """75 Whether the client has already been authorized.76 """77 self.Authorized = bool()78 79class Extension(object):80 def __init__(self):81 self.ProtocolVersion = long()82 self.ExtensionId = long()83 self.Name = str()84 self.Realm = long()85class EyetrackerEvents(Events):86 __events__ = ("OnCalibrationStarted", "OnCalibrationStopped", "OnFramerateChanged", "OnTrackBoxChanged", "OnXConfigurationChanged", "OnGazeDataReceived", "OnError")87class Eyetracker(BasicEyetracker):88 def __init__(self, message_passer):89 BasicEyetracker.__init__(self, message_passer)90 91 self.events = EyetrackerEvents()92 93 self._do_subscribe (1040, BasicEyetracker.ChannelHandlerFunctor(self._event_converter_CalibrationStarted, self._event_CalibrationStarted))94 self._do_subscribe (1050, BasicEyetracker.ChannelHandlerFunctor(self._event_converter_CalibrationStopped, self._event_CalibrationStopped))95 self._do_subscribe (1640, BasicEyetracker.ChannelHandlerFunctor(self._event_converter_FramerateChanged, self._event_FramerateChanged))96 self._do_subscribe (1410, BasicEyetracker.ChannelHandlerFunctor(self._event_converter_TrackBoxChanged, self._event_TrackBoxChanged))97 self._do_subscribe (1450, BasicEyetracker.ChannelHandlerFunctor(self._event_converter_XConfigurationChanged, self._event_XConfigurationChanged))98 self._do_subscribe (1280, BasicEyetracker.ChannelHandlerFunctor(self._event_converter_GazeDataReceived, self._event_GazeDataReceived))99 100 self._on_error_connection = self._message_passer.add_error_handler(self._on_error)101 102 def _on_error(self, error):103 self.events.OnError(error)104 105 def GetAuthorizeChallenge(self, realmId, algorithms, callback = None, *args, **kwargs):106 """107 Parameters:108 realmId: The realm to unauthorize109 algorithms: A list of encryption algorithms110 """111 response_callback = None112 if callback is not None:113 if not callable(callback): 114 raise ValueError("response_callback must be callable")115 response_callback = lambda error, response: callback(error, response, *args, **kwargs)116 self.get_auth_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_AuthorizeChallenge,117 response_callback=response_callback)118 119 params = tetio.ParamStack()120 params.push_uint32 (realmId)121 params.push_vector_uint32 (algorithms)122 123 self._message_passer.execute_request (1900,124 params,125 self.get_auth_response_handler)126 if response_callback is None:127 return self.get_auth_response_handler.wait_for_result() 128 129 def _response_converter_AuthorizeChallenge(self, payload):130 # opcode: 1900131 reader = ParamStackReader(payload) 132 response = AuthorizeChallenge()133 response.RealmId = reader.pop() # element: realm_ (type: uint32)134 response.Algorithm = reader.pop() # element: algorithm (type: uint32)135 response.ChallengeData = reader.pop() # element: challenge_data (type: blob)136 137 return response138 def ValidateChallengeResponse(self, realmId, algorithm, responseData, callback = None, *args, **kwargs):139 """140 Parameters:141 realmId: The realm to unauthorize142 algorithm: A encryption algorithm used for this challenge143 responseData: The challenge response data144 """145 response_callback = None146 if callback is not None:147 if not callable(callback): 148 raise ValueError("response_callback must be callable")149 response_callback = lambda error, response: callback(error, response, *args, **kwargs)150 self.validate_challenge_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,151 response_callback=response_callback)152 153 params = tetio.ParamStack()154 params.push_uint32 (realmId)155 params.push_uint32 (algorithm)156 params.push_blob (responseData)157 158 self._message_passer.execute_request (1910,159 params,160 self.validate_challenge_response_handler)161 162 if response_callback is None:163 return self.validate_challenge_response_handler.wait_for_result()164 def EnumerateFramerates(self, callback = None, *args, **kwargs):165 """166 Returns an enumeration of all framerates supported by this eyetracker.167 """168 response_callback = None169 if callback is not None:170 if not callable(callback): 171 raise ValueError("response_callback must be callable")172 response_callback = lambda error, response: callback(error, response, *args, **kwargs)173 self.enumerate_framerates_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_AvailableFramerates,174 response_callback=response_callback)175 176 params = tetio.ParamStack()177 178 self._message_passer.execute_request (1630,179 params,180 self.enumerate_framerates_response_handler)181 182 if response_callback is None:183 return self.enumerate_framerates_response_handler.wait_for_result()184 185 def _response_converter_AvailableFramerates(self, payload):186 # opcode: 1630187 reader = ParamStackReader(payload) 188 return reader.pop() # element: framerates (type: vector_fixed15x16)189 190 191 def SetFramerate(self, framerate, callback = None, *args, **kwargs):192 """193 Sets the eyetracker framerate.194 Parameters:195 framerate: The desired framerate. Must be one of the values returned by the enumerate framerate method196 """197 response_callback = None198 if callback is not None:199 if not callable(callback): 200 raise ValueError("response_callback must be callable")201 response_callback = lambda error, response: callback(error, response, *args, **kwargs)202 # conversation: framerate_set203 # archetype: request-response204 # opcode: 1620205 self.set_framerate_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,206 response_callback=response_callback)207 208 params = tetio.ParamStack()209 params.push_float32_as_fixed_15x16 (framerate)210 211 self._message_passer.execute_request (1620,212 params,213 self.set_framerate_response_handler)214 215 if response_callback is None:216 return self.set_framerate_response_handler.wait_for_result()217 218 def GetFramerate(self, callback = None, *args, **kwargs):219 """220 gets the current eyetracker framerate221 """222 response_callback = None223 if callback is not None:224 if not callable(callback): 225 raise ValueError("response_callback must be callable")226 response_callback = lambda error, response: callback(error, response, *args, **kwargs)227 # conversation: framerate_get228 # archetype: request-response229 # opcode: 1610230 self.get_framerate_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_FramerateInfo,231 response_callback=response_callback)232 233 params = tetio.ParamStack()234 235 self._message_passer.execute_request (1610,236 params,237 self.get_framerate_response_handler)238 239 if response_callback is None:240 return self.get_framerate_response_handler.wait_for_result()241 242 def _response_converter_FramerateInfo(self, payload):243 # opcode: 1610244 reader = ParamStackReader(payload) 245 return reader.pop() # element: framerate (type: fixed15x16) 246 247 248 def _event_converter_FramerateChanged(self, payload):249 # event: FramerateChanged250 # channel: 1640251 reader = ParamStackReader(payload)252 data = reader.pop() # element: framerate (type: fixed15x16)253 254 return data255 256 def _event_FramerateChanged(self, error, event_args):257 self.events.OnFramerateChanged(error, event_args) 258 259 def GetLowblinkMode(self, callback = None, *args, **kwargs):260 response_callback = None261 if callback is not None:262 if not callable(callback): 263 raise ValueError("response_callback must be callable")264 response_callback = lambda error, response: callback(error, response, *args, **kwargs)265 # conversation: lowblink_get_enabled266 # archetype: request-response267 # opcode: 1920268 self.get_lowblink_mode_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_LowblinkMode,269 response_callback=response_callback)270 271 params = tetio.ParamStack()272 273 self._message_passer.execute_request (1920,274 params,275 self.get_lowblink_mode_response_handler)276 277 if response_callback is None:278 return self.get_lowblink_mode_response_handler.wait_for_result()279 280 def _response_converter_LowblinkMode(self, payload):281 # opcode: 1920282 reader = ParamStackReader(payload) 283 return reader.pop() > 0 # element: enabled (type: uint32)284 285 def SetLowblinkMode(self, enabled, callback = None, *args, **kwargs):286 """287 Parameters:288 enabled: not documented289 """290 response_callback = None291 if callback is not None:292 if not callable(callback): 293 raise ValueError("response_callback must be callable")294 response_callback = lambda error, response: callback(error, response, *args, **kwargs)295 # conversation: lowblink_set_enabled296 # archetype: request-response297 # opcode: 1930298 self.set_lowblink_mode_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,299 response_callback=response_callback)300 301 params = tetio.ParamStack()302 params.push_uint32 (enabled)303 304 self._message_passer.execute_request (1930,305 params,306 self.set_lowblink_mode_response_handler)307 308 if response_callback is None:309 return self.set_lowblink_mode_response_handler.wait_for_result()310 311 312 313 def DumpImages(self, count, frequency, callback = None, *args, **kwargs):314 """315 Parameters:316 count: not documented317 frequency: not documented318 """319 response_callback = None320 if callback is not None:321 if not callable(callback): 322 raise ValueError("response_callback must be callable")323 response_callback = lambda error, response: callback(error, response, *args, **kwargs)324 # conversation: dump_images325 # archetype: request-response326 # opcode: 1500327 self.dump_images_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,328 response_callback=response_callback)329 330 params = tetio.ParamStack()331 params.push_uint32 (count)332 params.push_uint32 (frequency)333 334 self._message_passer.execute_request (1500,335 params,336 self.dump_images_response_handler)337 338 if response_callback is None:339 return self.dump_images_response_handler.wait_for_result()340 341 def GetDiagnosticReport(self, include_images, callback = None, *args, **kwargs):342 """343 Returns a diagnostic report.344 Parameters:345 include_images: not documented346 """347 response_callback = None348 if callback is not None:349 if not callable(callback): 350 raise ValueError("response_callback must be callable")351 response_callback = lambda error, response: callback(error, response, *args, **kwargs)352 # conversation: get_diagnostic_report353 # archetype: request-response354 # opcode: 1510355 self.get_diag_report_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_DiagnosticReport,356 response_callback=response_callback)357 358 params = tetio.ParamStack()359 params.push_uint32 (include_images)360 361 self._message_passer.execute_request (1510,362 params,363 self.get_diag_report_response_handler)364 365 if response_callback is None:366 return self.get_diag_report_response_handler.wait_for_result()367 368 def _response_converter_DiagnosticReport(self, payload):369 # opcode: 1510370 reader = ParamStackReader(payload) 371 return reader.pop() # element: report (type: blob)372 373 374 375 def SetUnitName(self, name, callback = None, *args, **kwargs):376 """377 Sets the eyetracker name.378 Parameters:379 name: The desired name. Can only contain alphanumeric characters, punctuations or spaces380 """381 response_callback = None382 if callback is not None:383 if not callable(callback): 384 raise ValueError("response_callback must be callable")385 response_callback = lambda error, response: callback(error, response, *args, **kwargs)386 # conversation: name_set387 # archetype: request-response388 # opcode: 1710389 self.set_unit_info_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,390 response_callback=response_callback)391 392 params = tetio.ParamStack()393 params.push_string (name)394 395 self._message_passer.execute_request (1710,396 params,397 self.set_unit_info_response_handler)398 399 if response_callback is None:400 return self.set_unit_info_response_handler.wait_for_result()401 402 def GetUnitName(self, callback = None, *args, **kwargs):403 """404 gets the eyetracker name405 """406 response_callback = None407 if callback is not None:408 if not callable(callback): 409 raise ValueError("response_callback must be callable")410 response_callback = lambda error, response: callback(error, response, *args, **kwargs)411 self.get_unit_name_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_NameInfo,412 response_callback=response_callback)413 414 params = tetio.ParamStack()415 416 self._message_passer.execute_request (1700,417 params,418 self.get_unit_name_response_handler)419 if response_callback is None:420 return self.get_unit_name_response_handler.wait_for_result() 421 def _response_converter_NameInfo(self, payload):422 # opcode: 1700423 reader = ParamStackReader(payload) 424 return reader.pop() # element: name (type: string)425 426 427 def GetUnitInfo(self, callback = None, *args, **kwargs):428 """429 Returns information about the eyetracker430 """431 response_callback = None432 if callback is not None:433 if not callable(callback): 434 raise ValueError("response_callback must be callable")435 response_callback = lambda error, response: callback(error, response, *args, **kwargs)436 self.get_unit_info_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_UnitInfo,437 response_callback=response_callback)438 439 params = tetio.ParamStack()440 441 self._message_passer.execute_request (1420,442 params,443 self.get_unit_info_response_handler)444 if response_callback is None:445 return self.get_unit_info_response_handler.wait_for_result() 446 447 def _response_converter_UnitInfo(self, payload):448 # opcode: 1420449 reader = ParamStackReader(payload) 450 response = UnitInfo()451 response.SerialNumber = reader.pop() # element: serial (type: string)452 response.Model = reader.pop() # element: model (type: string)453 response.Generation = reader.pop() # element: generation (type: string)454 response.FirmwareVersion = reader.pop() # element: version (type: string)455 456 return response457 def GetPayperuseInfo(self, callback = None, *args, **kwargs):458 """459 Returns PayPerUse info about the eyetracker460 """461 response_callback = None462 if callback is not None:463 if not callable(callback): 464 raise ValueError("response_callback must be callable")465 response_callback = lambda error, response: callback(error, response, *args, **kwargs)466 self.get_ppu_info_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_PayPerUseInfo,467 response_callback=response_callback)468 469 params = tetio.ParamStack()470 471 self._message_passer.execute_request (1600,472 params,473 self.get_ppu_info_response_handler)474 if response_callback is None:475 return self.get_ppu_info_response_handler.wait_for_result() 476 477 def _response_converter_PayPerUseInfo(self, payload):478 # opcode: 1600479 reader = ParamStackReader(payload) 480 response = PayperuseInfo()481 response.Enabled = reader.pop() > 0 # element: enabled (type: uint32)482 response.Realm = reader.pop() # element: realm (type: uint32)483 response.Authorized = reader.pop() > 0 # element: authorized (type: uint32)484 485 return response 486 def StartCalibration(self, callback = None, *args, **kwargs):487 """488 Puts the eyetracker into the calibration state489 """490 response_callback = None491 if callback is not None:492 if not callable(callback): 493 raise ValueError("response_callback must be callable")494 response_callback = lambda error, response: callback(error, response, *args, **kwargs)495 self.start_calibration_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,496 response_callback=response_callback)497 498 params = tetio.ParamStack()499 500 self._message_passer.execute_request (1010,501 params,502 self.start_calibration_response_handler)503 504 if response_callback is None:505 return self.start_calibration_response_handler.wait_for_result() 506 507 508 def StopCalibration(self, callback = None, *args, **kwargs):509 """510 Makes the eyetracker leave the calibration state511 """512 response_callback = None513 if callback is not None:514 if not callable(callback): 515 raise ValueError("response_callback must be callable")516 response_callback = lambda error, response: callback(error, response, *args, **kwargs)517 518 self.stop_calibration_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,519 response_callback=response_callback)520 521 params = tetio.ParamStack()522 523 self._message_passer.execute_request (1020,524 params,525 self.stop_calibration_response_handler)526 if response_callback is None:527 return self.stop_calibration_response_handler.wait_for_result() 528 def ClearCalibration(self, callback = None, *args, **kwargs):529 """530 Deletes all samples from the calibration under construction buffer.531 This method should be called before starting a new calibration532 """533 response_callback = None534 if callback is not None:535 if not callable(callback): 536 raise ValueError("response_callback must be callable")537 response_callback = lambda error, response: callback(error, response, *args, **kwargs)538 self.clear_calibration_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,539 response_callback=response_callback) 540 params = tetio.ParamStack()541 542 self._message_passer.execute_request (1060,543 params,544 self.clear_calibration_response_handler)545 if response_callback is None:546 return self.clear_calibration_response_handler.wait_for_result() 547 def _event_converter_CalibrationStarted(self, payload):548 # event: CalibrationStarted549 # channel: 1040550 data = CalibrationStartedEventArgs() 551 return data552 553 def _event_CalibrationStarted(self, error, event_args):554 self.events.OnCalibrationStarted(error, event_args)555 556 def _event_converter_CalibrationStopped(self, payload):557 # event: CalibrationStopped558 # channel: 1050559 data = CalibrationStoppedEventArgs() 560 return data561 562 def _event_CalibrationStopped(self, error, event_args):563 self.events.OnCalibrationStopped(error, event_args)564 def AddCalibrationPoint(self, point, callback = None, *args, **kwargs):565 """566 Collects calibration data for a specific calibration point.567 Parameters:568 point: Position of the calibration target point on the screen. The point must be in normalized coordinates, i e the point (0.0,0.0) corresponds to the upper left corner on the screen and the point (1.0,1.0) corresponds to the lower right corner of the screen569 """570 response_callback = None571 if callback is not None:572 if not callable(callback): 573 raise ValueError("response_callback must be callable")574 response_callback = lambda error, response: callback(error, response, *args, **kwargs)575 # conversation: begin_add_point_2576 # archetype: request-response577 # opcode: 1030578 self.add_calib_point_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,579 response_callback=response_callback)580 581 params = tetio.ParamStack()582 params.push_float64_as_fixed_22x41 (point.x)583 params.push_float64_as_fixed_22x41 (point.y)584 params.push_uint32 (3)585 586 self._message_passer.execute_request (1030,587 params,588 self.add_calib_point_response_handler)589 590 if response_callback is None:591 return self.add_calib_point_response_handler.wait_for_result() 592 593 def RemoveCalibrationPoint(self, point, callback = None, *args, **kwargs):594 """595 Removes all data associated with a specific calibration point from596 the in-construction calibration buffer. Does not affect the currently597 set calibration. The caller can decide if data should be removed from598 both eyes or from one specific eye.599 Parameters:600 point: The calibration point to clear.601 """602 response_callback = None603 if callback is not None:604 if not callable(callback): 605 raise ValueError("response_callback must be callable")606 response_callback = lambda error, response: callback(error, response, *args, **kwargs)607 self.remove_calib_point_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,608 response_callback=response_callback)609 610 params = tetio.ParamStack()611 params.push_float64_as_fixed_22x41 (point.x)612 params.push_float64_as_fixed_22x41 (point.y)613 params.push_uint32 (3)614 615 self._message_passer.execute_request (1080,616 params,617 self.remove_calib_point_response_handler)618 619 if response_callback is None:620 return self.remove_calib_point_response_handler.wait_for_result()621 622 def ComputeCalibration(self, callback = None, *args, **kwargs):623 """624 Computes new calibration parameters based on the data in the625 in-construction buffer. The data and calibration parameters is copied to the626 calibration in use buffer if the call succeeds.627 """628 response_callback = None629 if callback is not None:630 if not callable(callback): 631 raise ValueError("response_callback must be callable")632 response_callback = lambda error, response: callback(error, response, *args, **kwargs)633 self.compute_calibration_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,634 response_callback=response_callback)635 636 params = tetio.ParamStack()637 638 self._message_passer.execute_request (1070,639 params,640 self.compute_calibration_response_handler)641 if response_callback is None:642 return self.compute_calibration_response_handler.wait_for_result()643 644 def GetCalibration(self, callback = None, *args, **kwargs):645 """646 Gets the current calibration in use from the tracker647 """648 649 response_callback = None650 if callback is not None:651 if not callable(callback): 652 raise ValueError("response_callback must be callable")653 response_callback = lambda error, response: callback(error, response, *args, **kwargs)654 self.get_calib_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_Calibration,655 response_callback=response_callback)656 657 params = tetio.ParamStack()658 659 self._message_passer.execute_request (1100,660 params,661 self.get_calib_response_handler)662 if response_callback is None:663 return self.get_calib_response_handler.wait_for_result() 664 def _response_converter_Calibration(self, payload):665 # opcode: 1100 666 return converters.ToCalibration(payload)667 def SetCalibration(self, calibration, callback = None, *args, **kwargs):668 """669 Sets the current calibration670 Parameters:671 calibration: not documented672 """673 response_callback = None674 if callback is not None:675 if not callable(callback): 676 raise ValueError("response_callback must be callable")677 response_callback = lambda error, response: callback(error, response, *args, **kwargs)678 self.set_calib_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,679 response_callback=response_callback) 680 params = tetio.ParamStack()681 params.push_blob (calibration.rawData)682 683 self._message_passer.execute_request (1110,684 params,685 self.set_calib_response_handler)686 if response_callback is None:687 return self.set_calib_response_handler.wait_for_result() 688 689 def StartTracking(self, callback = None, *args, **kwargs):690 response_callback = None691 if callback is not None:692 if not callable(callback): 693 raise ValueError("response_callback must be callable")694 response_callback = lambda error, response: callback(error, response, *args, **kwargs)695 self.start_tracking_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,696 response_callback=response_callback)697 698 params = tetio.ParamStack()699 params.push_uint32 (1280) # 1280 is the gaze data stream700 params.push_vector_uint32 ([]) # empty list means all columns701 702 self._message_passer.execute_request (1220,703 params,704 self.start_tracking_response_handler)705 if response_callback is None:706 return self.start_tracking_response_handler.wait_for_result() 707 def StopTracking(self, callback = None, *args, **kwargs):708 response_callback = None709 if callback is not None:710 if not callable(callback): 711 raise ValueError("response_callback must be callable")712 response_callback = lambda error, response: callback(error, response, *args, **kwargs)713 self.stop_tracking_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,714 response_callback=response_callback)715 716 params = tetio.ParamStack()717 params.push_uint32 (1280) # 1280 is the gaze data stream 718 719 self._message_passer.execute_request (1230,720 params,721 self.stop_tracking_response_handler)722 if response_callback is None:723 return self.stop_tracking_response_handler.wait_for_result() 724 725 def _event_converter_GazeDataReceived(self, payload):726 # channel: 1280727 data = GazeDataItem()728 reader = ParamStackReader(payload)729 data_row = reader.pop() # element: gaze (type: tree)730 731 data.Timestamp = self.get_gaze_data_column(data_row, GazeDataConstants.TimeStamp)732 733 data.LeftEyePosition3D = Point3D._node_converter(self.get_gaze_data_column(data_row, GazeDataConstants.LeftEyePosition3D))734 data.LeftEyePosition3DRelative = Point3D._node_converter(self.get_gaze_data_column(data_row, GazeDataConstants.LeftEyePosition3DRelative))735 data.LeftGazePoint3D = Point3D._node_converter(self.get_gaze_data_column(data_row, GazeDataConstants.LeftGazePoint3D))736 data.LeftGazePoint2D = Point2D._node_converter(self.get_gaze_data_column(data_row, GazeDataConstants.LeftGazePoint2D))737 data.LeftPupil = self.get_gaze_data_column(data_row, GazeDataConstants.LeftPupil)738 data.LeftValidity = self.get_gaze_data_column(data_row, GazeDataConstants.LeftValidity)739 740 data.RightEyePosition3D = Point3D._node_converter(self.get_gaze_data_column(data_row, GazeDataConstants.RightEyePosition3D))741 data.RightEyePosition3DRelative = Point3D._node_converter(self.get_gaze_data_column(data_row, GazeDataConstants.RightEyePosition3DRelative))742 data.RightGazePoint3D = Point3D._node_converter(self.get_gaze_data_column(data_row, GazeDataConstants.RightGazePoint3D))743 data.RightGazePoint2D = Point2D._node_converter(self.get_gaze_data_column(data_row, GazeDataConstants.RightGazePoint2D))744 data.RightPupil = self.get_gaze_data_column(data_row, GazeDataConstants.RightPupil)745 data.RightValidity = self.get_gaze_data_column(data_row, GazeDataConstants.RightValidity)746 747 if self.has_gaze_data_column(data_row, GazeDataConstants.TrigSignal):748 data.TrigSignal = self.get_gaze_data_column(data_row, GazeDataConstants.TrigSignal)749 750 return data751 752 def _event_GazeDataReceived(self, error, event_args):753 self.events.OnGazeDataReceived(error, event_args)754 def has_gaze_data_column(self, row, column_id):755 if row.type != 3000: # XDS Row756 raise ValueError("Can only extract XDS Columns from XDS nodes")757 for node in row:758 if node.type == 3001: # XDS column759 if node[0] == column_id:760 return True761 return False762 def get_gaze_data_column(self, row, column_id):763 if row.type != 3000: # XDS Row764 raise ValueError("Can only extract XDS Columns from XDS nodes")765 for node in row:766 if node.type == 3001: # XDS column767 if node[0] == column_id:768 return node[1]769 raise ValueError("Cannot find %s" % column_id)770 771 def GetTrackBox(self, callback = None, *args, **kwargs):772 """773 Returns the current head movement box.774 """775 response_callback = None776 if callback is not None:777 if not callable(callback): 778 raise ValueError("response_callback must be callable")779 response_callback = lambda error, response: callback(error, response, *args, **kwargs)780 self.get_track_box_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_TrackBox,781 response_callback=response_callback)782 783 params = tetio.ParamStack()784 785 self._message_passer.execute_request (1400,786 params,787 self.get_track_box_response_handler)788 789 if response_callback is None:790 return self.get_track_box_response_handler.wait_for_result() 791 792 def _response_converter_TrackBox(self, payload):793 # opcode: 1400794 reader = ParamStackReader(payload) 795 response = TrackBox()796 response.Point1 = Point3D._node_converter(reader.pop()) # element: p1 (type: tree)797 response.Point2 = Point3D._node_converter(reader.pop()) # element: p2 (type: tree)798 response.Point3 = Point3D._node_converter(reader.pop()) # element: p3 (type: tree)799 response.Point4 = Point3D._node_converter(reader.pop()) # element: p4 (type: tree)800 response.Point5 = Point3D._node_converter(reader.pop()) # element: p5 (type: tree)801 response.Point6 = Point3D._node_converter(reader.pop()) # element: p6 (type: tree)802 response.Point7 = Point3D._node_converter(reader.pop()) # element: p7 (type: tree)803 response.Point8 = Point3D._node_converter(reader.pop()) # element: p8 (type: tree)804 805 return response806 807 def _event_converter_TrackBoxChanged(self, payload):808 # event: TrackBoxChanged809 # channel: 1410810 data = TrackBoxChangedEventArgs() 811 return data812 813 def _event_TrackBoxChanged(self, error, event_args):814 self.events.OnTrackBoxChanged(error, event_args)815 816 def EnableExtension(self, extensionId, callback = None, *args, **kwargs):817 response_callback = None818 if callback is not None:819 if not callable(callback): 820 raise ValueError("response_callback must be callable")821 response_callback = lambda error, response: callback(error, response, *args, **kwargs)822 self.enable_extension_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,823 response_callback=response_callback)824 825 params = tetio.ParamStack()826 params.push_uint32 (extensionId)827 828 self._message_passer.execute_request (1800,829 params,830 self.enable_extension_response_handler)831 if response_callback is None:832 return self.enable_extension_response_handler.wait_for_result() 833 834 def GetAvailableExtensions(self, callback = None, *args, **kwargs):835 response_callback = None836 if callback is not None:837 if not callable(callback): 838 raise ValueError("response_callback must be callable")839 response_callback = lambda error, response: callback(error, response, *args, **kwargs)840 self.get_avail_extensions_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_AvailableExtensions,841 response_callback=response_callback)842 843 params = tetio.ParamStack()844 845 self._message_passer.execute_request (1810,846 params,847 self.get_avail_extensions_response_handler)848 if response_callback is None:849 return self.get_avail_extensions_response_handler.wait_for_result() 850 851 def _response_converter_AvailableExtensions(self, payload):852 # opcode: 1810853 reader = ParamStackReader(payload) 854 node = reader.pop() # element: available_extensions (type: tree)855 856 return self._convert_node_to_extension_list(node)857 858 def GetEnabledExtensions(self, callback = None, *args, **kwargs):859 response_callback = None860 if callback is not None:861 if not callable(callback): 862 raise ValueError("response_callback must be callable")863 response_callback = lambda error, response: callback(error, response, *args, **kwargs)864 self.get_enabled_extensions_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_EnabledExtensions,865 response_callback=response_callback)866 867 params = tetio.ParamStack()868 869 self._message_passer.execute_request (1820,870 params,871 self.get_enabled_extensions_response_handler)872 873 if response_callback is None:874 return self.get_enabled_extensions_response_handler.wait_for_result() 875 def _response_converter_EnabledExtensions(self, payload):876 # opcode: 1820877 reader = ParamStackReader(payload) 878 node = reader.pop() # element: enabled_extensions (type: tree)879 880 return self._convert_node_to_extension_list(node)881 882 883 def _convert_node_to_extension_list(self, node):884 if not isinstance(node, Node):885 raise TypeError("node must be of type Node")886 887 if not node[0] is not 9000: #9000 is Extension type ID888 raise ValueError("node parameter has unexpected format")889 890 extension_list = []891 for i in range(len(node)):892 if i > 0: # ignore type item893 if len(node[i]) is not 4:894 raise ValueError("expected Extension node with four members")895 ext = Extension()896 ext.ProtocolVersion = node[i][0]897 ext.ExtensionId = node[i][1]898 ext.Name = node[i][2]899 ext.Realm = node[i][3]900 extension_list.append(ext)901 902 return extension_list903 904 def GetXConfiguration(self, callback = None, *args, **kwargs):905 response_callback = None906 if callback is not None:907 if not callable(callback): 908 raise ValueError("response_callback must be callable")909 response_callback = lambda error, response: callback(error, response, *args, **kwargs)910 self.get_x_config_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_XConfiguration,911 response_callback=response_callback)912 913 params = tetio.ParamStack()914 915 self._message_passer.execute_request (1430,916 params,917 self.get_x_config_response_handler)918 if response_callback is None:919 return self.get_x_config_response_handler.wait_for_result() 920 921 def _response_converter_XConfiguration(self, payload):922 # opcode: 1430923 reader = ParamStackReader(payload) 924 response = XConfiguration()925 response.UpperLeft = Point3D._node_converter(reader.pop()) # element: upper_left (type: tree)926 response.UpperRight = Point3D._node_converter(reader.pop()) # element: upper_right (type: tree)927 response.LowerLeft = Point3D._node_converter(reader.pop()) # element: lower_left (type: tree)928 929 return response930 def SetXConfiguration(self, UpperLeft, UpperRight, LowerLeft, callback = None, *args, **kwargs):931 response_callback = None932 if callback is not None:933 if not callable(callback): 934 raise ValueError("response_callback must be callable")935 response_callback = lambda error, response: callback(error, response, *args, **kwargs)936 self.set_x_config_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,937 response_callback=response_callback)938 939 params = tetio.ParamStack()940 Converter.to_tree(params, UpperLeft)941 Converter.to_tree(params, UpperRight)942 Converter.to_tree(params, LowerLeft)943 944 # write empty tool data945 params.push_node_prolog(1 << 16 | 256)946 params.push_uint32(12345)947 948 self._message_passer.execute_request (1440,949 params,950 self.set_x_config_response_handler)951 if response_callback is None:952 return self.set_x_config_response_handler.wait_for_result() 953 954 def _event_converter_XConfigurationChanged(self, payload):955 # event: XconfigChanged956 # channel: 1450957 data = XConfiguration()958 959 reader = ParamStackReader(payload)960 data.UpperLeft = Point3D._node_converter(reader.pop()) # element: upper_left (type: tree)961 data.UpperRight = Point3D._node_converter(reader.pop()) # element: upper_right (type: tree)962 data.LowerLeft = Point3D._node_converter(reader.pop()) # element: lower_left (type: tree)963 # ignore tool data element: guidlist (type: vector_string)964 return data965 966 def _event_XConfigurationChanged(self, error, event_args):967 self.events.OnXConfigurationChanged(error, event_args)968 969 970 def SetIlluminationMode(self, illuminationMode, callback = None, *args, **kwargs):971 """972 Sets the illumination mode.973 Parameters:974 illuminationMode: The name of the desired illumination mode975 """976 response_callback = None977 if callback is not None:978 if not callable(callback): 979 raise ValueError("response_callback must be callable")980 response_callback = lambda error, response: callback(error, response, *args, **kwargs)981 982 self.set_illum_mode_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=None,983 response_callback=response_callback)984 985 params = tetio.ParamStack()986 params.push_string (illuminationMode)987 988 self._message_passer.execute_request (2020,989 params,990 self.set_illum_mode_response_handler)991 992 if response_callback is None:993 return self.set_illum_mode_response_handler.wait_for_result()994 995 def GetIlluminationMode(self, callback = None, *args, **kwargs):996 """997 gets the name of the current illumination mode998 """999 response_callback = None1000 if callback is not None:1001 if not callable(callback): 1002 raise ValueError("response_callback must be callable")1003 response_callback = lambda error, response: callback(error, response, *args, **kwargs)1004 self.get_illum_mode_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_GetIlluminationMode,1005 response_callback=response_callback)1006 1007 params = tetio.ParamStack()1008 1009 self._message_passer.execute_request (2010,1010 params,1011 self.get_illum_mode_response_handler)1012 if response_callback is None:1013 return self.get_illum_mode_response_handler.wait_for_result() 1014 def _response_converter_GetIlluminationMode(self, payload):1015 reader = ParamStackReader(payload) 1016 return reader.pop() # element: illumination mode (type: string)1017 1018 def EnumerateIlluminationModes(self, callback = None, *args, **kwargs):1019 """1020 Returns all illumination modes supported by this eye tracker1021 1022 """1023 response_callback = None1024 if callback is not None:1025 if not callable(callback): 1026 raise ValueError("response_callback must be callable")1027 response_callback = lambda error, response: callback(error, response, *args, **kwargs)1028 1029 self.enumerate_illum_mode_response_handler = BasicEyetracker.ResponseHandlerFunctor(data_converter=self._response_converter_EnumerateIlluminationModes,1030 response_callback=response_callback)1031 1032 params = tetio.ParamStack()1033 1034 self._message_passer.execute_request (2030,1035 params,1036 self.enumerate_illum_mode_response_handler)1037 1038 if response_callback is None:1039 return self.enumerate_illum_mode_response_handler.wait_for_result()1040 1041 def _response_converter_EnumerateIlluminationModes(self, payload):1042 reader = ParamStackReader(payload) 1043 return reader.pop() # element: illumination modes (type: vector_string)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!