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


Python Session.addTrigger方法代码示例

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


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

示例1: Recorder

# 需要导入模块: from session import Session [as 别名]
# 或者: from session.Session import addTrigger [as 别名]

#.........这里部分代码省略.........
            self.startTime = datetime.now()
            self.server.start()
        except:
            print("something went wrong")
            self.server.exitFlag = True
            raise socket.timeout("Could not connect to Delsys Station")
        else:
            if self.showRunMeta.ui.cbEternity.checkState() == 0:
                duration = self.showRunMeta.ui.timeEdit.time()
                d = duration.second() + duration.minute()*60
                
                self.runPinger.start(d*1000)
                self.ui.elapsedTime.setRange(0,d)
            elif self.showRunMeta.ui.cbEternity.checkState() == 2:
                self.ui.elapsedTime.setRange(0,0)
            
            self.pinger.start()
            
            self.ui.tbStop.setEnabled(True)
            self.ui.tbTrigger.setEnabled(True)
            self.ui.tbStart.setEnabled(False)
            
            name = self.showRunMeta.ui.leCurrentRun.text()
            self.session.addRun(name)
            if self.kinectRecorder is not None:
                self.kinectRecorder.startRecording(self.newpath+'\\'+name+'.oni')            
            self.ui.elapsedTime.setRange(0,d)
    
    def stop(self):
        ''' stop recording due to button press or timeout
        - setup buttons
        - stop timers
        - stop server
        - kill kinectRecorder
        - add item to list of runs
        '''
        self.ui.tbStop.setEnabled(False)
        self.ui.tbTrigger.setEnabled(False)
        self.ui.tbStart.setEnabled(True)
        self.ui.elapsedTime.reset()
        
        QListWidgetItem(self.showRunMeta.ui.leCurrentRun.text(),
                        self.showRunMeta.ui.lwRuns)
        
        self.showRunMeta.ui.leCurrentRun.setText(str(len(self.session.runs)))
        self.server.exitFlag = True
        self.server.stop()

        self.runPinger.stop()
        self.pinger.stop()
        
        self.session.stopRun(self.server.buffer)
        self.server.buffer = None
        if self.kinectRecorder is not None:
            self.kinectRecorder.stopRecording()
        self.server.flush()
        
    def trigger(self):
        ''' add a trigger '''
        print("trigger")
        trigger = self.server.buffer[0].shape[1]
        self.session.addTrigger(trigger)
        
    def ping(self):
        ''' update progress bar and plots everytime
        new data is available 
        '''
        elapsed = int((datetime.now()-self.startTime).total_seconds())
        self.ui.elapsedTime.setValue(elapsed)
        
        for p in range(len(self.plots)):
            if self.server.buffer[0].shape[1] < 5000:
                self.plots[p].plot(self.server.buffer[0][p], clear=True)
            else:
                self.plots[p].plot(self.server.buffer[0][p,-5000:], clear=True)
    
    def openPlotter(self, item=None):
        if self.plotter is None:
            self.plotter = Plotter()
        if item is not None:
            self.plotter.load([os.path.join(self.session.dir, item.text()) + ".pk"])
        self.plotter.show()
        
    def closeEvent(self, event):
        if self.notSavedState:
            reply = QMessageBox.question(self, 'QMessageBox.question()',
                                            'Do you want to first save the current session?',
                                            QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
        else:
            reply = QMessageBox.No

        if reply == QMessageBox.Yes:
            self.save()
        elif reply == QMessageBox.Cancel:
            event.ignore()
            return
      
        if not self.server.exitFlag:
            self.stop()
        event.accept()
开发者ID:Yakisoba007,项目名称:PyTrigno,代码行数:104,代码来源:recorder.py


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