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


Python iohub.Computer类代码示例

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


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

示例1: spinDownTest

    def spinDownTest(self):
        # OK, we have collected the number of requested getEvents, that have returned >0 events
        # so _close psychopy window
        self.psychoWindow.close()

        # disable high priority in both processes
        Computer.disableHighPriority()
开发者ID:balajisriram,项目名称:psychopy,代码行数:7,代码来源:run.py

示例2: pumpMsgTasklet

 def pumpMsgTasklet(self, sleep_interval):
     import pythoncom
     while self._running:
         stime=Computer.getTime()
         if pythoncom.PumpWaitingMessages() == 1:
             break
         dur = sleep_interval - (Computer.getTime()-stime)
         gevent.sleep(max(0.0, dur))
开发者ID:NSalem,项目名称:psychopy,代码行数:8,代码来源:server.py

示例3: test_getTime

    def test_getTime(self):
        ta = Computer.currentSec()
        tb = Computer.currentTime()
        tc = Computer.getTime()
        tp = getTime()

        assert ta < tb < tc < tp
        assert tp - ta < 0.002
开发者ID:Lx37,项目名称:psychopy,代码行数:8,代码来源:test_computer.py

示例4: checkForEvents

 def checkForEvents(self):
     # get the time we request events from the ioHub
     stime=Computer.currentTime()
     r = self.hub.getEvents()
     if r and len(r) > 0:
         # so there were events returned in the request, so include this getEvent request in the tally
         etime=Computer.currentTime()
         dur=etime-stime
         return r, dur*1000.0
     return None,None
开发者ID:balajisriram,项目名称:psychopy,代码行数:10,代码来源:run.py

示例5: test_getTime

    def test_getTime(self):
        ta = Computer.currentSec()
        tb = Computer.currentTime()
        tc = Computer.getTime()
        tp = getTime()

        assert ta <= tb <= tc <= tp
        assert tp - ta < 0.002

        ta = getTime()
        tb = self.io.getTime()
        tc = self.io.getTime()
        tp = getTime()

        assert ta <= tb <= tc <= tp
        assert tp - ta < 0.01
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:16,代码来源:test_computer.py

示例6: _createByteChangeSerialEvent

    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,代码行数:32,代码来源:__init__.py

示例7: local2RemoteTime

 def local2RemoteTime(self,local_time=None):
     """
     Converts a local time (sec.msec format) to the corresponding remote
     computer time, using the current offset and drift measures.
     """
     if local_time is None:
         local_time=Computer.currentSec()
     return self.getDrift()*local_time+self.getOffset()
开发者ID:balajisriram,项目名称:psychopy,代码行数:8,代码来源:net.py

示例8: startHubProcess

def startHubProcess():
    io = launchHubServer()
    assert io != None

    io_proc = Computer.getIoHubProcess()
    io_proc_pid = io_proc.pid
    assert io_proc != None and io_proc_pid > 0

    return io
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:9,代码来源:testutil.py

示例9: test_processorCounts

    def test_processorCounts(self):
        get_puc = Computer.getProcessingUnitCount()
        cc = Computer.core_count
        puc = Computer.processing_unit_count

        assert puc == get_puc
        assert type(cc) is int
        assert type(puc) is int
        assert puc > 0
        assert cc > 0
        assert cc <= puc
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:11,代码来源:test_computer.py

示例10: sync

    def sync(self):
        sync_count=self.sync_batch_size
        sync_data=['SYNC_REQ',]

        feed=self.feed
        unpack=self.unpack
        pack=self.pack

        recvfrom=self.sock.recvfrom
        rcvBufferLength=self._rcvBufferLength

        remote_address=self.remote_iohub_address
        sendto=self.sock.sendto

        min_delay=1000.0
        min_local_time=0.0
        min_remote_time=0.0

        for s in range(sync_count):
            # send sync request
            sync_start=Computer.currentSec()
            sendto(pack(sync_data),remote_address)
            sync_start2=Computer.currentSec()

            # get reply
            feed(recvfrom(rcvBufferLength)[0])
            sync_rep,remote_time=unpack()
            sync_end=Computer.currentSec()
            rtt=sync_end-(sync_start+sync_start2)/2.0

            old_delay=min_delay
            min_delay=min(min_delay,rtt)

            if old_delay!=min_delay:
                min_local_time=(sync_end+sync_start)/2.0
                min_remote_time=remote_time

        return min_delay, min_local_time, min_remote_time
开发者ID:balajisriram,项目名称:psychopy,代码行数:38,代码来源:net.py

示例11: run

    def run(self,*args):
        """
        The run method contains your experiment logic. It is equal to what 
        would be in your main psychopy experiment script.py file in a standard 
        psychopy experiment setup. That is all there is too it really.
        """
        run_demo=True
     
        kb=self.hub.devices.kb
        evt_sub=self.hub.devices.evt_sub
            
        # This demo does not display a PsychoPy window, instead it just prints
        # keyboard event info. received from the local keyboard device and keyboard
        # events received from the RemoteEventSubscriber device. Inform the user of this...
        # 
        msg_dialog=MessageDialog("This demo does not create a PsychoPy window.\nInstead local and subscribed keyboard event info is simply printed to stdout.\n\nOnce the demo has started, press 'ESCAPE' to quit.\n\nPress OK to continue or Cancel to abort the demo.",
                     title="PsychoPy.ioHub PUB - SUB Event Demo", 
                     dialogType=MessageDialog.IMPORTANT_DIALOG,display_index=0)

        if msg_dialog.show() == MessageDialog.OK_RESULT:
            # wait until 'ESCAPE' is pressed, or quit after 15 seconds of no kb events.
            self.hub.clearEvents('all')
            last_event_time=Computer.getTime()
            while run_demo is True and Computer.getTime()-last_event_time<15.0:
                local_kb_events=kb.getEvents()
                for event in local_kb_events:
                    print('* Local KB Event: {etime}\t{ekey}\t{edelay}'.format(
                        etime=event.time,ekey=event.key,edelay=event.delay))
                    last_event_time=event.time
                    if event.key == u'ESCAPE':
                        run_demo=False
                        break
                subscribed_kb_events=evt_sub.getEvents()
                for event in subscribed_kb_events:
                    print('# Subscribed KB Event: {etime}\t{ekey}\t{edelay}'.format(
                        etime=event.time, ekey=event.key,edelay=event.delay))
                self.hub.wait(0.1)
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:37,代码来源:run.py

示例12: test_getProcesses

    def test_getProcesses(self):
        assert Computer.is_iohub_process is False
        assert Computer.psychopy_process == Computer.getCurrentProcess()
        assert Computer.current_process == Computer.psychopy_process
        assert Computer.iohub_process == Computer.getIoHubProcess()
        assert Computer.iohub_process.pid == Computer.iohub_process_id

        assert Computer.getCurrentProcess().is_running()
        assert Computer.getIoHubProcess().is_running()
        assert Computer.getIoHubProcess().parent() == Computer.getCurrentProcess()
开发者ID:DennisEckmeier,项目名称:psychopy,代码行数:10,代码来源:test_computer.py

示例13: _createMultiByteSerialEvent

 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,代码行数:16,代码来源:__init__.py

示例14: stopHubProcess

def stopHubProcess():
    from psychopy.iohub.client import ioHubConnection

    io = ioHubConnection.getActiveConnection()
    assert io != None

    io_proc = Computer.getIoHubProcess()
    io_proc_pid = io_proc.pid
    assert io_proc != None and psutil.pid_exists(io_proc_pid)

    # Stop iohub server, ending process.
    io.quit()

    # Enure iohub proc has terminated.
    assert not psutil.pid_exists(io_proc_pid)

    assert ioHubConnection.getActiveConnection() is None
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:17,代码来源:testutil.py

示例15: test_procPriority

    def test_procPriority(self):
        psycho_proc = Computer.psychopy_process
        iohub_proc = Computer.getIoHubProcess()

        psycho_priority = Computer.getProcessPriority(psycho_proc)
        iohub_priority = Computer.getProcessPriority(iohub_proc)
        assert psycho_priority == 'normal'
        assert iohub_priority == 'normal'

        priority_change_ok = Computer.enableHighPriority()
        new_psycho_priority = Computer.getProcessPriority(psycho_proc)
        assert priority_change_ok == False or new_psycho_priority == 'high'

        priority_change_ok = self.io.enableHighPriority()
        new_io_priority = Computer.getProcessPriority(iohub_proc)
        assert priority_change_ok == False or new_io_priority == 'high'

        priority_change_ok = Computer.disableHighPriority()
        new_psycho_priority = Computer.getProcessPriority(psycho_proc)
        assert priority_change_ok == False or new_psycho_priority == 'normal'

        priority_change_ok = self.io.disableHighPriority()
        new_io_priority = Computer.getProcessPriority(iohub_proc)
        assert priority_change_ok == False or new_io_priority == 'normal'
开发者ID:Lx37,项目名称:psychopy,代码行数:24,代码来源:test_computer.py


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