Public Member Functions | |
| __init__ (self, host='localhost', port=6555) | |
| request (self, category, request, values) | |
| create_json (self, category, request, values) | |
| parse_json (self, jsonmsg) | |
| revive (self) | |
| close (self) | |
Public Attributes | |
| host = host | |
| port = port | |
| bool | DEBUG = False |
| float | response_timeout = 1.0 |
| sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
Protected Member Functions | |
| _get_responses (self) | |
Protected Attributes | |
| dict | _responses |
| _request_lock = Lock() | |
| _debugfile = open('DEBUG_output.txt', 'w') | |
| _debuglock = Lock() | |
| bool | _listening = True |
| _listenthread = Thread(target=self._get_responses, args=[]) | |
class for connections with the EyeTribe tracker
| pygaze._eyetracker.pytribe.connection.__init__ | ( | self, | |
| host = 'localhost', | |||
| port = 6555 ) |
Initializes the connection with the EyeTribe tracker
keyword arguments
host -- a string indicating the host IP, NOTE: currently only
'localhost' is supported (default = 'localhost')
port -- an integer indicating the port number, NOTE: currently
only 6555 is supported (default = 6555)
|
protected |
INTERNAL USE ONLY. This method is run in a sub-Thread, to listen
to the EyeTribe, and to process all its responses. Responses are
stored in a
| pygaze._eyetracker.pytribe.connection.close | ( | self | ) |
Closes the connection to the EyeTribe tracker
| pygaze._eyetracker.pytribe.connection.create_json | ( | self, | |
| category, | |||
| request, | |||
| values ) |
Creates a new json message, in the format that is required by the
EyeTribe tracker; these messages consist of a categort, a request and
a (list of) value(s), which can be thought of as class.method.value
(for more info, see: http://dev.theeyetribe.com/api/)
arguments
category -- query category (string), e.g. 'tracker',
'calibration', or 'heartbeat'
request -- the request message (string), e.g. 'get' for the
'tracker' category
values -- a dict of parameters and their values, e.g.
{"push":True, "version":1}
OR:
a list of parameters, e.g. ['push','iscalibrated']
OR:
None to pass no values at all
keyword arguments
None
returns
jsonmsg -- a string in json format, that can be directly sent to
the EyeTribe tracker
| pygaze._eyetracker.pytribe.connection.parse_json | ( | self, | |
| jsonmsg ) |
Parses a json message as those that are usually returned by the
EyeTribe tracker
(for more info, see: http://dev.theeyetribe.com/api/)
arguments
jsonmsg -- a string in json format
keyword arguments
None
returns
msg -- a dict containing the information in the json message;
this dict has the following content:
{ "category": "tracker",
"request": "get",
"statuscode": 200,
"values": { "push":True,
"iscalibrated":True
}
}
| pygaze._eyetracker.pytribe.connection.request | ( | self, | |
| category, | |||
| request, | |||
| values ) |
Send a message over the connection
arguments
category -- string indicating the query category
request -- string indicating the actual request of the message
values -- dict or list containing parameters of the request
| pygaze._eyetracker.pytribe.connection.revive | ( | self | ) |
Re-establishes a connection
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| bool pygaze._eyetracker.pytribe.connection.DEBUG = False |
| pygaze._eyetracker.pytribe.connection.host = host |
| pygaze._eyetracker.pytribe.connection.port = port |
| float pygaze._eyetracker.pytribe.connection.response_timeout = 1.0 |
| pygaze._eyetracker.pytribe.connection.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |