def test1():
    streamhandler = StreamHandler()
    
    # Configure and start
    dev = FakeDigital(streamhandler = streamhandler)
    dev.configure( 
                                nb_channel = 30,
                                sampling_rate =1000000.,
                                buffer_length = 60.,
                                packet_size = 20,
                                )
    dev.initialize()
    dev.start()
    
    app = QtGui.QApplication([])
    
    #~ w1=OscilloscopeDigital(stream = dev.streams[0])
    #~ w1.show()
    #~ w1.set_params(xsize = 5., decimate= 500)

    w2=OscilloscopeDigital(stream = dev.streams[0])
    w2.show()
    w2.set_params(xsize = 30, mode = 'scroll', decimate= 500, auto_decimate = True)
    

    
    app.exec_()
    
    # Stope and release the device
    dev.stop()
    dev.close()
def test1():
    streamhandler = StreamHandler()
    
    # Configure and start
    dev = MeasurementComputingMultiSignals(streamhandler = streamhandler)
    dev.configure( board_num = 0,
                          sampling_rate =1000.,
                          buffer_length = 60.,
                                )
    dev.initialize()
    dev.start()
    
    app = QtGui.QApplication([])
    w1=Oscilloscope(stream = dev.streams[0])
    w1.auto_gain_and_offset(mode = 2)
    w1.set_params(xsize = 20., refresh_interval = 100, mode = 'scan', ylims = [-8., 8.])
    w1.show()
    
    w2 = TimeFreq(stream = dev.streams[0], max_visible_on_open = 4)
    w2.set_params(refresh_interval = 100, xsize = 2.)
    w2.show()
    
    w3=OscilloscopeDigital(stream = dev.streams[1])
    w3.set_params(xsize = 20, mode = 'scan')    
    w3.show()
    
    app.exec_()
    
    # Stope and release the device
    dev.stop()
    dev.close()
def trigger_digital1():
    streamhandler = StreamHandler()
    
    # Configure and start
    dev = FakeDigital(streamhandler = streamhandler)
    dev.configure( 
                                nb_channel = 32,
                                sampling_rate =100000.,
                                buffer_length = 60.,
                                packet_size = 100,
                                )
    dev.initialize()
    dev.start()

    def print_pos(pos):
        print pos
    
    trigger = DigitalTrigger(stream = dev.streams[0],
                                    front = '-', 
                                    channel = 0,
                                    #~ debounce_mode = 'no-debounce',
                                    debounce_mode = 'after-stable',
                                    #~ debounce_mode = 'before-stable',
                                    debounce_time = 0.05,
                                    callbacks = [ print_pos,  ]
                                    )

    
    app = QtGui.QApplication([])
    
    w1=OscilloscopeDigital(stream = dev.streams[0])
    w1.show()
    visibles = np.ones(dev.nb_channel, dtype = bool)
    visibles[1:] = False
    w1.set_params(xsize = 4.7,
                                    mode = 'scan',
                                visibles = visibles,
                                refresh_interval = .1)


    time.sleep(.5)
    #~ w1.auto_gain_and_offset(mode = 2)

    
    app.exec_()
    print 1
    # Stope and release the device
    trigger.stop()
    print 2
    dev.stop()
    print 3
    dev.close()
    print 4