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


Python Cube.start方法代码示例

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


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

示例1: MainWindow

# 需要导入模块: from cube import Cube [as 别名]
# 或者: from cube.Cube import start [as 别名]
class MainWindow(QtGui.QMainWindow):
    ## Configures initial settings of the window.
    #
    # Initialize data, plots, imported functions and timers
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Variables
        self.resetData()
        ## Reference update plot timer
        #
        # Qt4 timer to trigger the @updatePlot function
        self.timer = QtCore.QTimer(self)
        ## Qt4 timer for activity
        self.timerActivity = QtCore.QTimer(self)

        # Qt signals
        # start button signal
        QtCore.QObject.connect(self.ui.pButton_Start,
                               QtCore.SIGNAL('clicked()'), self.start)
        # stop button signal
        QtCore.QObject.connect(self.ui.pButton_Stop,
                               QtCore.SIGNAL('clicked()'), self.stop)
        # start cube button signal
        QtCore.QObject.connect(self.ui.pButton_Cube,
                               QtCore.SIGNAL('clicked()'), self.startCube)

        # start reset button signal
        QtCore.QObject.connect(self.ui.pButton_Reset,
                               QtCore.SIGNAL('clicked()'), self.resetData)

        # timer signal
        QtCore.QObject.connect(self.timer,
                               QtCore.SIGNAL('timeout()'), self.updatePlot)
        QtCore.QObject.connect(self.timerActivity,
                               QtCore.SIGNAL('timeout()'), self.updateActivity)

        # Configure UI
        # cBoxs
        self.ui.cBox_Port.addItems(self.getPorts())
        self.ui.cBox_Speed.addItems(["9600", "57600", "115200"])
        self.ui.cBox_Speed.setCurrentIndex(2)
        self.setUILocked(False)

        self.ui.cBox_IMU.addItems(['MPU-9150', 'SP_RAZOR'])

        # Configure plots
        self.configurePlot(self.ui.plt1, RANGE_ACCEL, "Acceleration", "g")
        self.configurePlot(self.ui.plt2, RANGE_GYRO, "Angular Velocity",
                           "deg/seg")
        self.configurePlot(self.ui.plt3, RANGE_MAG, "Flux", "Gs")
        self.configurePlot(self.ui.plt4, RANGE_EULER, "Euler angles DMP",
                           "degree")
        self.configurePlot(self.ui.plt5, RANGE_EULER, "Euler angles", "degree")
        self.configurePlot(self.ui.plt6, RANGE_ACCEL, "Linear Acceleration",
                           "g")

    ## Executed when pressing Start Buttton
    #
    # Starts data adquisition and timers, blocking the UI elements
    # @param self The object pointer.
    def start(self):
        ## Reference for the Threaded serial adquisition
        #
        # Threaded adquisition for a serial device with interrupts
        # using Qt4 signals
        self.data = SerialThread(str(self.ui.cBox_IMU.currentText()))
        self.data.openPort(str(self.ui.cBox_Port.currentText()),
                           int(self.ui.cBox_Speed.currentText()))
        ## Register the data object with the cube
        self.cube = Cube(self.data)

        # start file
        if self.ui.chBox_export.isChecked():
            ## export data
            self.csv = CSVExport()
            self.ui.statusbar.showMessage("Exporting data")
        else:
            self.ui.statusbar.showMessage("Adquiring data")

        # start data thread
        self.data.start()
        # dataThread new data signal
        self.connect(self.data, QtCore.SIGNAL('newData()'),
                     self.updateData)
        # update UI
        self.setUILocked(True)
        # start timer for updating plot
        self.timer.start(20)
        # start timer every second for activity
        self.timerActivity.start(1000)

        ## Reference for the activity detection algorithm
        #
        # Activity detection algorithm propossed by Dr. Pablo Reyes
        self.activity = ActivityDetection(70, 175, 20, .02)

        ## Reference for the fall detection algorithm
#.........这里部分代码省略.........
开发者ID:ssepulveda,项目名称:ICB_TT,代码行数:103,代码来源:main.py


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