예제 #1
0
    def view_factory(self):
        """Construct a new View into the device's data.

        :return: A View-compatible instance.
        """
        view = View(self.stream_buffer, self.calibration)
        view.on_close = lambda: self.stream_process_unregister(view)
        self.stream_process_register(view)
        return view
예제 #2
0
class TestView(unittest.TestCase):

    def setUp(self):
        self.b = StreamBuffer(2.0, [10, 10], sampling_frequency=1000)
        self.v = View(stream_buffer=self.b, calibration=None)
        self.b.insert(usb_packet_factory(0, 2))
        self.b.process()
        self.v.open()

    def tearDown(self):
        self.v.close()

    def test_sample_conversion(self):
        self.assertEqual((('hello', ), {'one': 1}), self.v.ping('hello', one=1))
        self.assertEqual(252, self.v.time_to_sample_id(2.0))
        self.assertEqual(2.0, self.v.sample_id_to_time(252))
        self.assertEqual(152, self.v.time_to_sample_id(1.9))

    def test_statistics_get(self):
        s1 = self.v.statistics_get(-2, -1, units='samples')
예제 #3
0
 def setUp(self):
     self.b = StreamBuffer(2000, [10, 10], sampling_frequency=1000)
     self.v = View(stream_buffer=self.b, calibration=None)
     self.b.insert(usb_packet_factory(0, 2))
     self.b.process()
     self.v.open()
예제 #4
0
 def test_open_close(self):
     v = View(stream_buffer=None, calibration=None)
     v.open()
     self.assertEqual((('hello', ), {'one': 1}), v.ping('hello', one=1))
     v.close()