Esempio n. 1
0
    def test_get_callback(self):
        write("Callback test:  changing PV must be updated\n")
        global NEWVALS
        mypv = PV(pvnames.updating_pv1)
        NEWVALS = []
        def onChanges(pvname=None, value=None, char_value=None, **kw):
            write('PV %s %s, %s Changed!\n' % (pvname, repr(value), char_value))
            NEWVALS.append(repr(value))

        mypv.add_callback(onChanges)
        write('Added a callback.  Now wait for changes...\n')

        t0 = time.time()
        while time.time() - t0 < 3:
            time.sleep(1.e-4)
        write('   saw %i changes.\n' % len(NEWVALS))
        assert len(NEWVALS) > 3
        mypv.clear_callbacks()
Esempio n. 2
0
    def test_waveform_callback_with_count_arg(self):
        values = []

        wf = PV(pvnames.char_arr_pv, count=32)
        def onChanges(pvname=None, value=None, char_value=None, **kw):
            write( 'PV %s %s, %s Changed!\n' % (pvname, repr(value), char_value))
            values.append( value)

        wf.add_callback(onChanges)
        write('Added a callback.  Now wait for changes...\n')

        t0 = time.time()
        while time.time() - t0 < 3:
            time.sleep(1.e-4)
            if len(values)>0:
                break

        self.failUnless(len(values) > 0)
        self.assertEquals(len(values[0]),32)

        wf.clear_callbacks()