当前位置: 首页>>代码示例>>Python>>正文


Python EventConstants.getClass方法代码示例

本文整理汇总了Python中psychopy.iohub.EventConstants.getClass方法的典型用法代码示例。如果您正苦于以下问题:Python EventConstants.getClass方法的具体用法?Python EventConstants.getClass怎么用?Python EventConstants.getClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在psychopy.iohub.EventConstants的用法示例。


在下文中一共展示了EventConstants.getClass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _handleEvents

# 需要导入模块: from psychopy.iohub import EventConstants [as 别名]
# 或者: from psychopy.iohub.EventConstants import getClass [as 别名]
    def _handleEvents(self, events):
        # saves many events to pytables table at once.
        # EVENTS MUST ALL BE OF SAME TYPE!!!!!
        try:
            #ioHub.print2err("_handleEvent: ",self.active_experiment_id,self.active_session_id)

            if self.checkForExperimentAndSessionIDs(len(events)) is False:
                return False

            event=events[0]

            etype=event[DeviceEvent.EVENT_TYPE_ID_INDEX]
            #ioHub.print2err("etype: ",etype)
            eventClass=EventConstants.getClass(etype)
            etable=self.TABLES[eventClass.IOHUB_DATA_TABLE]
            #ioHub.print2err("eventClass: etable",eventClass,etable)

            np_events=[]
            for event in events:
                event[DeviceEvent.EVENT_EXPERIMENT_ID_INDEX]=self.active_experiment_id
                event[DeviceEvent.EVENT_SESSION_ID_INDEX]=self.active_session_id
                np_events.append(tuple(event))

            np_array= N.array(np_events,dtype=eventClass.NUMPY_DTYPE)
            #ioHub.print2err('np_array:',np_array)
            etable.append(np_array)

            self.bufferedFlush(len(np_events))

        except ioHubError, e:
            print2err(e)
开发者ID:MPBagger,项目名称:psychopy,代码行数:33,代码来源:__init__.py

示例2: _convertToMonoAveraged

# 需要导入模块: from psychopy.iohub import EventConstants [as 别名]
# 或者: from psychopy.iohub.EventConstants import getClass [as 别名]
 def _convertToMonoAveraged(self, prev_event, current_event):
     mono_evt=[]
     binoc_field_names = EventConstants.getClass(EventConstants.BINOCULAR_EYE_SAMPLE).CLASS_ATTRIBUTE_NAMES
     #print2err("binoc_field_names: ",len(binoc_field_names),"\n",binoc_field_names)
     status = current_event[binoc_field_names.index('status')]
     for field in self.io_event_fields:
         if field in binoc_field_names:
             mono_evt.append(current_event[binoc_field_names.index(field)])
         elif field == 'eye':
             mono_evt.append(LEFT_EYE)
         elif field.endswith('_type'):
             mono_evt.append(int(current_event[binoc_field_names.index('left_%s'%(field))]))
         else:
             #print2err("binoc status: ",status)
             if status == 0:
                 lfv = float(current_event[binoc_field_names.index('left_%s'%(field))])
                 rfv = float(current_event[binoc_field_names.index('right_%s'%(field))])
                 mono_evt.append((lfv+rfv)/2.0)
             elif status == 2:
                 mono_evt.append(float(current_event[binoc_field_names.index('left_%s'%(field))]))
             elif status == 20:
                 mono_evt.append(float(current_event[binoc_field_names.index('right_%s'%(field))]))
             elif status == 22:
                 # both eyes have missing data, so use data from left eye (does not really matter)
                 mono_evt.append(float(current_event[binoc_field_names.index('left_%s'%(field))]))
             else:
                 ValueError("Unknown Sample Status: %d"%(status))
     mono_evt[self.io_event_fields.index('type')] = EventConstants.MONOCULAR_EYE_SAMPLE
     if self.isValidSample(mono_evt):
         self._convertPosToAngles(mono_evt)
         if prev_event:
             self._addVelocity(prev_event, mono_evt)
     return mono_evt
开发者ID:EducationalTestingService,项目名称:Confero,代码行数:35,代码来源:eyetracker.py

示例3: _handleEvents

# 需要导入模块: from psychopy.iohub import EventConstants [as 别名]
# 或者: from psychopy.iohub.EventConstants import getClass [as 别名]
    def _handleEvents(self, events):
        try:
            if self.checkForExperimentAndSessionIDs(len(events)) is False:
                return False

            event = events[0]

            etype = event[DeviceEvent.EVENT_TYPE_ID_INDEX]
            eventClass = EventConstants.getClass(etype)
            etable = self.TABLES[eventClass.IOHUB_DATA_TABLE]

            np_events = []
            for event in events:
                event[DeviceEvent.EVENT_EXPERIMENT_ID_INDEX] = self.active_experiment_id
                event[DeviceEvent.EVENT_SESSION_ID_INDEX] = self.active_session_id
                np_events.append(tuple(event))

            np_array = np.array(np_events, dtype=eventClass.NUMPY_DTYPE)
            #ioHub.print2err('np_array:',np_array)
            etable.append(np_array)
            self.bufferedFlush(len(np_events))
        except ioHubError as e:
            print2err(e)
        except Exception:
            printExceptionDetailsToStdErr()
开发者ID:jonathanoroberts,项目名称:psychopy,代码行数:27,代码来源:__init__.py

示例4: initializeForSampleType

# 需要导入模块: from psychopy.iohub import EventConstants [as 别名]
# 或者: from psychopy.iohub.EventConstants import getClass [as 别名]
    def initializeForSampleType(self,in_evt):
        self.sample_type = MONOCULAR_EYE_SAMPLE  #in_evt[DeviceEvent.EVENT_TYPE_ID_INDEX]
        #print2err("self.sample_type: ",self.sample_type,", ",EventConstants.getName(self.sample_type))
        self.io_sample_class = EventConstants.getClass(self.sample_type)
        self.io_event_fields = self.io_sample_class.CLASS_ATTRIBUTE_NAMES
        #print2err("self.io_sample_class: ",self.io_sample_class,", ",len(self.io_event_fields),"\n>>",self.io_event_fields)
        self.io_event_ix = self.io_sample_class.CLASS_ATTRIBUTE_NAMES.index

        if in_evt[DeviceEvent.EVENT_TYPE_ID_INDEX] == BINOCULAR_EYE_SAMPLE:
            self.convertEvent = self._convertToMonoAveraged
            self.isValidSample = lambda x: x[self.io_event_ix('status')] != 22
        else:
            self.convertEvent = self._convertMonoFields
            self.isValidSample = lambda x: x[self.io_event_ix('status')] == 0
开发者ID:EducationalTestingService,项目名称:Confero,代码行数:16,代码来源:eyetracker.py

示例5: _handleEvent

# 需要导入模块: from psychopy.iohub import EventConstants [as 别名]
# 或者: from psychopy.iohub.EventConstants import getClass [as 别名]
    def _handleEvent(self, event):
        try:
            if self.checkForExperimentAndSessionIDs(event) is False:
                return False
            etype = event[DeviceEvent.EVENT_TYPE_ID_INDEX]
            eventClass = EventConstants.getClass(etype)
            etable = self.TABLES[eventClass.IOHUB_DATA_TABLE]
            event[DeviceEvent.EVENT_EXPERIMENT_ID_INDEX] = self.active_experiment_id
            event[DeviceEvent.EVENT_SESSION_ID_INDEX] = self.active_session_id

            np_array = np.array([tuple(event), ], dtype=eventClass.NUMPY_DTYPE)
            etable.append(np_array)
            self.bufferedFlush()
        except Exception:
            print2err("Error saving event: ", event)
            printExceptionDetailsToStdErr()
开发者ID:jonathanoroberts,项目名称:psychopy,代码行数:18,代码来源:__init__.py

示例6: __init__

# 需要导入模块: from psychopy.iohub import EventConstants [as 别名]
# 或者: from psychopy.iohub.EventConstants import getClass [as 别名]
    def __init__(self, rootScriptPathDir, config=None):
        self._session_id=None
        self._experiment_id=None

        self.log("Server Time Offset: {0}".format(Computer.globalClock.getLastResetTime()))

        self._hookManager=None
        self.emrt_file=None
        self.config=config
        self.devices=[]
        self.deviceMonitors=[]
        self.sessionInfoDict=None
        self.experimentInfoList=None
        self.filterLookupByInput={}
        self.filterLookupByOutput={}
        self.filterLookupByName={}  
        self._hookDevice=None
        ioServer.eventBuffer=deque(maxlen=config.get('global_event_buffer',2048))

        self._running=True
        
        # start UDP service
        self.udpService=udpServer(self,':%d'%config.get('udp_port',9000))

        try:
            # initial dataStore setup
            if 'data_store' in config and psychopy.iohub._DATA_STORE_AVAILABLE:
                experiment_datastore_config=config.get('data_store')
                default_datastore_config_path=os.path.join(IO_HUB_DIRECTORY,'datastore','default_datastore.yaml')
                #print2err('default_datastore_config_path: ',default_datastore_config_path)
                _dslabel,default_datastore_config=load(file(default_datastore_config_path,'r'), Loader=Loader).popitem()

                for default_key,default_value in default_datastore_config.iteritems():
                    if default_key not in experiment_datastore_config:
                        experiment_datastore_config[default_key]=default_value
                                
                if experiment_datastore_config.get('enable', True):
                    #print2err("Creating ioDataStore....")

                    resultsFilePath=rootScriptPathDir
                    self.createDataStoreFile(experiment_datastore_config.get('filename','events')+'.hdf5',resultsFilePath,'a',experiment_datastore_config)

                    #print2err("Created ioDataStore.")
        except:
            print2err("Error during ioDataStore creation....")
            printExceptionDetailsToStdErr()


        #built device list and config from initial yaml config settings
        try:
            for iodevice in config.get('monitor_devices',()):
                for device_class_name,deviceConfig in iodevice.iteritems():
                    #print2err("======================================================")
                    #print2err("Started load process for: {0}".format(device_class_name))
                    self.createNewMonitoredDevice(device_class_name,deviceConfig)
        except:
            print2err("Error during device creation ....")
            printExceptionDetailsToStdErr()
            raise ioHubError("Error during device creation ....")


        # Add PubSub device listeners to other event types
        try:
            for d in self.devices:
                if d.__class__.__name__ == "EventPublisher":
                    monitored_event_ids=d._event_listeners.keys()
                    for eid in monitored_event_ids:
                        event_device_class=EventConstants.getClass(eid).PARENT_DEVICE
                        for ed in self.devices:
                            if ed.__class__ == event_device_class:
                                ed._addEventListener(d,[eid,])
                                break
                            
        except Exception, e:
            print2err("Error PubSub Device listener association ....")
            printExceptionDetailsToStdErr()
            raise e
开发者ID:BrainTech,项目名称:psychopy,代码行数:79,代码来源:server.py


注:本文中的psychopy.iohub.EventConstants.getClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。