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


Python View.newDataIO方法代码示例

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


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

示例1: User

# 需要导入模块: from Display import View [as 别名]
# 或者: from Display.View import newDataIO [as 别名]
class User(QDialog, Ui_Dialog):
    """
    Class documentation goes here.
    """
    def __init__(self, parent = None):
        """
        Constructor
        """
#        QDialog.__init__(self, parent, Qt.FramelessWindowHint)
        QDialog.__init__(self, parent)
        self.setupUi(self)
        
        self.nerfModel = Model()
        
        pipeInData = gen_sin(F = 1.0, AMP = 100.0,  T = 2.0)
        self.nerfModel.SendPipe(pipeInData)
        
        self.dispView = View(None, VIEWER_REFRESH_RATE, CHIN_PARAM)

        self.dispView.show()
        self.data = []
        self.isLogData = False
        
        # Create float_spin for each input channel
        self.ctrl_all = []
        for (trig_id, name, type, value) in CHOUT_PARAM:
            exec interp('self.ctrl_#{name} = CtrlChannel(hostDialog=self, name=name, id=trig_id, type=type, value=value)')
            exec interp('self.connect(self.ctrl_#{name}.doubleSpinBox, SIGNAL("editingFinished()"), self.onNewWireIn)')
            exec interp('self.connect(self.ctrl_#{name}.doubleSpinBox, SIGNAL("valueChanged(double)"), self.onNewWireIn)')
            exec interp('self.ctrl_all.append(self.ctrl_#{name})')        
        
        # Timer for pulling data, separated from timer_display
        self.timer = QTimer(self)
        self.connect(self.timer, SIGNAL("timeout()"), self.onSyncData)       
        self.timer.start(VIEWER_REFRESH_RATE )
        
        
        self.on_horizontalSlider_valueChanged(5)
        


    def onSyncData(self):
        """
        Core function of Controller, which polls data from Model(fpga) and sends them to Viewer.
        """
        newData = []
        for xaddr, xtype in zip(DATA_OUT_ADDR, CH_TYPE):
            #newData[i] = self.nerfModel.ReadFPGA(DATA_OUT_ADDR[i], CH_TYPE[i])
#            if i == 3: 
#                newData[i] = newData[i] / 100
            newData.append(max(-16777216, min(16777216, self.nerfModel.ReadFPGA(xaddr, xtype))))
            print newData[0::6]   # printing 
            #        newSpike1 = self.nerfModel.ReadPipe(0xA0, 5000) # read ## bytes
#        newSpike2 = self.nerfModel.ReadPipe(0xA1, 5000) # read ## bytes
#        newSpike3 = self.nerfModel.ReadPipe(0xA2, 5000) # read ## bytes
#        newSpike4 = self.nerfModel.ReadPipe(0xA3, 5000) # read ## bytes
#        newSpike5 = self.nerfModel.ReadPipe(0xA4, 5000) # read ## bytes
        newSpike1 = ""
        newSpike2 = ""
        newSpike3 = ""
        newSpike4 = ""
        newSpike5 = ""
        

        #newSpike = "" # read ## bytes
        
        self.dispView.newDataIO(newData, [newSpike1, newSpike2, newSpike3, newSpike4, newSpike5])
        #self.dispView.newDataIO(newData, [])
        if (self.isLogData):
            self.data.append(newData)
        
    def onClkRate(self, value):   
        """ value = how many times of 1/10 real-time
        """
        # F_fpga = C * NUM_NEURON * V * F_emu ,  (C : cycles_per_neuron = 2,  V = 365)
        # if F_fpga = 200Mhz,  F_emu = 1khz)
        # halfcnt = F_fpga / F_neuron / 2 = F_fpga / (C * NUM_NEURON * V * F_emu) / 2
        NUM_CYCLE = 2
        newHalfCnt = 200 * (10 **6) / (NUM_CYCLE * NUM_NEURON * value * SAMPLING_RATE/10 ) /2 
        print 'halfcnt=%d' %newHalfCnt
        print 'value=%d' %value

        self.nerfModel.SendPara(bitVal = newHalfCnt, trigEvent = DATA_EVT_CLKRATE)
        
    def onNewWireIn(self):
        for ctrl in self.ctrl_all:
            newWireIn = ctrl.doubleSpinBox.value()
            if newWireIn != ctrl.currVal:
                ctrl.currValue = newWireIn
                if (ctrl.type == 'int32'):
                    bitVal = ConvertType(floor(newWireIn),  fromType = 'i',  toType = 'I')
#                    print bitVal
                elif (ctrl.type == 'float32'):
                    bitVal = ConvertType(newWireIn, fromType = 'f', toType = 'I')
                self.nerfModel.SendPara(bitVal = bitVal, trigEvent = ctrl.id)
                


    def plotData(self, data):
        from pylab import plot, show, subplot
#.........这里部分代码省略.........
开发者ID:wonjsohn,项目名称:sarcos,代码行数:103,代码来源:temp_Controls.py


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