class WebSocketHandler(tornado.websocket.WebSocketHandler):

    def open(self):
        self.websocket_ping_interval = 0
        self.websocket_ping_timeout = float("inf")
        self.app_state_control = ApplicationStateController(30)
        self.adaptation_loop = AdaptationLoop(self.app_state_control)
        self.adaptation_loop.liveWebSocket = self

        self.tobii_controller = TobiiController()
        self.tobii_controller.waitForFindEyeTracker()
        #self.initialize_detection_components()
        print self.tobii_controller.eyetrackers

        self.tobii_controller.activate(self.tobii_controller.eyetrackers.keys()[0])
        self.tobii_controller.startTracking()
        self.fixation_component = FixationDetector(self.tobii_controller, self.adaptation_loop)

        self.start_detection_components()
        print "tracking started"

    def start_detection_components(self):
        if (params.USE_FIXATION_ALGORITHM):
            self.fixation_component.restart_fixation_algorithm()
            self.fixation_component.start()
Exemple #2
0
class WebSocketHandler(tornado.websocket.WebSocketHandler):
    def open(self):
        self.websocket_ping_interval = 0
        self.websocket_ping_timeout = float("inf")
        self.app_state_control = ApplicationStateController(30)
        self.adaptation_loop = AdaptationLoop(self.app_state_control)
        self.adaptation_loop.liveWebSocket = self

        self.tobii_controller = TobiiController()
        self.tobii_controller.waitForFindEyeTracker()
        #self.initialize_detection_components()
        print self.tobii_controller.eyetrackers

        self.tobii_controller.activate(
            self.tobii_controller.eyetrackers.keys()[0])
        self.tobii_controller.startTracking()
        self.fixation_component = FixationDetector(self.tobii_controller,
                                                   self.adaptation_loop)

        self.start_detection_components()
        print "tracking started"

    def start_detection_components(self):
        if (params.USE_FIXATION_ALGORITHM):
            self.fixation_component.restart_fixation_algorithm()
            self.fixation_component.start()
Exemple #3
0
    def open(self):
        self.websocket_ping_interval = 0
        self.websocket_ping_timeout = float("inf")
        self.app_state_control = ApplicationStateController(30)
        self.adaptation_loop = AdaptationLoop(self.app_state_control)
        self.adaptation_loop.liveWebSocket = self

        self.tobii_controller = TobiiController()
        self.tobii_controller.waitForFindEyeTracker()
        #self.initialize_detection_components()
        print self.tobii_controller.eyetrackers

        self.tobii_controller.activate(
            self.tobii_controller.eyetrackers.keys()[0])
        self.tobii_controller.startTracking()
        self.fixation_component = FixationDetector(self.tobii_controller,
                                                   self.adaptation_loop)

        self.start_detection_components()
        print "tracking started"
    def __init__(self):
        #connects url with code

        self.tobii_controller = TobiiControllerNewSdk()
        self.tobii_controller.activate()
        self.app_state_control = ApplicationStateController(0)
        self.adaptation_loop = AdaptationLoop(self.app_state_control)

        self.fixation_component = FixationDetector(self.tobii_controller, self.adaptation_loop)
        self.emdat_component = EMDATComponent(self.tobii_controller, self.adaptation_loop, callback_time = params.EMDAT_CALL_PERIOD)
        self.ml_component = MLComponent(self.tobii_controller, self.adaptation_loop, callback_time = params.EMDAT_CALL_PERIOD, emdat_component = self.emdat_component)
        self.mouse_key_component = MouseKeyboardEventDetector(self.tobii_controller, self.adaptation_loop, self.emdat_component, params.USE_MOUSE, params.USE_KEYBOARD)
        websocket_dict = {TOBII_CONTROLLER: self.tobii_controller,
                         APPLICATION_STATE_CONTROLLER: self.app_state_control,
                         ADAPTATION_LOOP: self.adaptation_loop,
                         FIXATION_ALGORITHM: self.fixation_component,
                         EMDAT_COMPONENT: self.emdat_component,
                         ML_COMPONENT: self.ml_component,
                         MOUSE_KEY_COMPONENT: self.mouse_key_component}
        handlers = [
            (r"/", MainHandler),
            (r"/mmd", MMDHandler),
            (r"/questionnaire", QuestionnaireHandler),
            (r"/resume", ResumeHandler),
            (r"/userID", UserIDHandler),
            (r"/prestudy", PreStudyHandler), (r"/(Sample_bars.png)", tornado.web.StaticFileHandler, {'path': params.FRONT_END_STATIC_PATH + 'sample/'}),
                                             (r"/(Sample_bars_2.png)", tornado.web.StaticFileHandler, {'path': params.FRONT_END_STATIC_PATH + 'sample/'}),
            (r"/sample_MMD", SampleHandler), (r"/(ExampleMMD.png)", tornado.web.StaticFileHandler, {'path': params.FRONT_END_STATIC_PATH + 'sample/'}),
            (r"/sample_Q", SampleHandler2), (r"/(ExampleQ.png)", tornado.web.StaticFileHandler, {'path': params.FRONT_END_STATIC_PATH + 'sample/'}),
            (r"/calibration", CalibrationHandler), (r"/(blank_cross.jpg)", tornado.web.StaticFileHandler, {'path': params.FRONT_END_STATIC_PATH + 'sample/'}),
            (r"/tobii", TobiiHandler),
            (r"/ready", ReadyHandler),
            (r"/done", DoneHandler),
            (r"/final_question", FinalHandler), (r"/(post_question.png)", tornado.web.StaticFileHandler, {'path': params.FRONT_END_STATIC_PATH + 'sample/'}),
            (r"/done2", DoneHandler2),
            (r"/websocket", MMDWebSocket, dict(websocket_dict = websocket_dict))
        ]
        #connects to database
        self.conn = sqlite3.connect('database.db')
        #"global variable" to save current UserID of session
        UserID = -1;
        #global variable to track start and end times
        start_time = '';
        end_time = '';
        #where to look for the html files
        settings = dict(
            template_path=os.path.join(os.path.dirname(__file__), params.FRONT_END_TEMPLATE_PATH),
            static_path=os.path.join(os.path.dirname(__file__), params.FRONT_END_STATIC_PATH),
            debug=True,
        )
        #initializes web app
        tornado.web.Application.__init__(self, handlers, **settings)
    def open(self):
        self.websocket_ping_interval = 0
        self.websocket_ping_timeout = float("inf")
        self.app_state_control = ApplicationStateController(30)
        self.adaptation_loop = AdaptationLoop(self.app_state_control)
        self.adaptation_loop.liveWebSocket = self

        self.tobii_controller = TobiiController()
        self.tobii_controller.waitForFindEyeTracker()
        #self.initialize_detection_components()
        print self.tobii_controller.eyetrackers

        self.tobii_controller.activate(self.tobii_controller.eyetrackers.keys()[0])
        self.tobii_controller.startTracking()
        self.fixation_component = FixationDetector(self.tobii_controller, self.adaptation_loop)

        self.start_detection_components()
        print "tracking started"
    def __init__(self):
        # connects url with code
        self.tobii_controller = TobiiControllerNewSdk()
        self.tobii_controller.activate()
        self.app_state_control = ApplicationStateController(0)
        self.adaptation_loop = AdaptationLoop(self.app_state_control)

        self.fixation_component = FixationDetector(self.tobii_controller, self.adaptation_loop)
        self.emdat_component = EMDATComponent(self.tobii_controller, self.adaptation_loop, callback_time = params.EMDAT_CALL_PERIOD)
        self.ml_component = MLComponent(self.tobii_controller, self.adaptation_loop, callback_time = params.EMDAT_CALL_PERIOD, emdat_component = self.emdat_component)
        self.mouse_key_component = MouseKeyboardEventDetector(self.tobii_controller, self.adaptation_loop, self.emdat_component, params.USE_MOUSE, params.USE_KEYBOARD)
        websocket_dict = {TOBII_CONTROLLER: self.tobii_controller,
                          APPLICATION_STATE_CONTROLLER: self.app_state_control,
                          ADAPTATION_LOOP: self.adaptation_loop,
                          FIXATION_ALGORITHM: self.fixation_component,
                          EMDAT_COMPONENT: self.emdat_component,
                          ML_COMPONENT: self.ml_component,
                          MOUSE_KEY_COMPONENT: self.mouse_key_component}
        handlers = [
            (r"/", MainHandler),
            (r"/writePolygon", PolygonAjaxHandler),
            (r"/websocket", MMDWebSocket, dict(websocket_dict=websocket_dict))
        ]
        # connects to database
        self.conn = sqlite3.connect(params.USER_MODEL_STATE_PATH)
        # "global variable" to save current UserID of session
        UserID = -1;
        # global variable to track start and end times
        start_time = '';
        end_time = '';
        # where to look for the html files
        settings = dict(
            template_path=os.path.join(os.path.dirname(__file__), params.FRONT_END_TEMPLATE_PATH),
            static_path=os.path.join(os.path.dirname(__file__), params.FRONT_END_STATIC_PATH),
            debug=True,
        )
        # initializes web app
        tornado.web.Application.__init__(self, handlers, **settings)