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


Python Computer._getNextEventID方法代码示例

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


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

示例1: _createByteChangeSerialEvent

# 需要导入模块: from psychopy.iohub import Computer [as 别名]
# 或者: from psychopy.iohub.Computer import _getNextEventID [as 别名]
    def _createByteChangeSerialEvent(self, logged_time, read_time,
                                     prev_byte, new_byte):
        self._event_count += 1
        confidence_interval = read_time - self._last_poll_time

        prev_byte = ord(prev_byte)
        new_byte = ord(new_byte)

        try:
            if new_byte != 0:  # Button was pressed
                button = N.where(self._button_bytes == new_byte)[0][0]
                button_event = 'press'
            else:  # Button was released
                button = N.where(self._button_bytes == prev_byte)[0][0]
                button_event = 'release'
        except:
            # Handles when data rx does not match either N.where within the try
            return
        events = [
            0, 0, 0, Computer._getNextEventID(),
            EventConstants.PSTBOX_BUTTON,
            read_time,
            logged_time,
            read_time,
            confidence_interval,
            0.0,
            0,
            self.port,
            button,
            button_event
        ]
        self._addNativeEventToBuffer(events)
开发者ID:NSalem,项目名称:psychopy,代码行数:34,代码来源:__init__.py

示例2: _createMultiByteSerialEvent

# 需要导入模块: from psychopy.iohub import Computer [as 别名]
# 或者: from psychopy.iohub.Computer import _getNextEventID [as 别名]
 def _createMultiByteSerialEvent(self, logged_time, read_time):
     self._event_count += 1
     confidence_interval = read_time - self._last_poll_time
     elist=[0, 0, 0, Computer._getNextEventID(),
            EventConstants.SERIAL_INPUT,
            read_time,
            logged_time,
            read_time,
            confidence_interval,
            0.0,
            0,
            self.port,
            self._parser_state['parsed_event']
         ]
     self._addNativeEventToBuffer(elist)
     self._resetParserState()
开发者ID:NSalem,项目名称:psychopy,代码行数:18,代码来源:__init__.py

示例3: _poll

# 需要导入模块: from psychopy.iohub import Computer [as 别名]
# 或者: from psychopy.iohub.Computer import _getNextEventID [as 别名]
    def _poll(self):
        try:
            logged_time=getTime()

            if self.isConnected():            
                self._mcu.getSerialRx()
                if logged_time-self._last_sync_time>=self.time_sync_interval:
                    self._mcu._runTimeSync()
                    MCU._last_sync_time=logged_time

            if not self.isReportingEvents():
                return False

            confidence_interval=logged_time-self._last_callback_time
    
            events=self._mcu.getRxEvents()
            for event in events:             
                current_MCU_time=event.device_time#self.getSecTime()
                device_time=event.device_time
                if event.local_time is None:
                    event.local_time=logged_time
                delay=logged_time-event.local_time#current_MCU_time-device_time
                # local_time is in iohub time space already, so delay does not
                # need to be used to adjust iohub time
                iohub_time=event.local_time
                elist=None
                if event.getTypeInt()==T3Event.DIGITAL_INPUT_EVENT:
                    elist= [EventConstants.UNDEFINED,]*12
                    elist[4]=DigitalInputEvent.EVENT_TYPE_ID
                    elist[-1]=event.getDigitalInputByte()
                elif event.getTypeInt()==T3Event.ANALOG_INPUT_EVENT:
                    elist= [EventConstants.UNDEFINED,]*19
                    elist[4]=AnalogInputEvent.EVENT_TYPE_ID
                    for i,v in enumerate(event.ain_channels):
                        elist[(i+11)]=v            
                if elist:
                    elist[0]=0
                    elist[1]=0
                    elist[2]=0
                    elist[3]=Computer._getNextEventID()
                    elist[5]=device_time
                    elist[6]=logged_time
                    elist[7]=iohub_time
                    elist[8]=confidence_interval
                    elist[9]=delay
                    elist[10]=0
                   
                    self._addNativeEventToBuffer(elist)
                
            replies = self._mcu.getRequestReplies(True)
            for reply in replies:
                rid=reply.getID()
                if rid in self._request_dict.keys():
                    self._response_dict[rid]=reply
                    del self._request_dict[rid]
            
            self._last_callback_time=logged_time
            return True
        except Exception, e:
            print2err("--------------------------------")
            print2err("ERROR in MCU._poll: ",e)
            printExceptionDetailsToStdErr()
            print2err("---------------------")
开发者ID:BrainTech,项目名称:psychopy,代码行数:65,代码来源:__init__.py


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