示例#1
0
def run_dashboard(window, source_class, source_kwargs):
    vehicle = Vehicle()
    dashboard = Dashboard(window, vehicle)
    dashboard.source = source_class(**source_kwargs)
    vehicle.add_source(dashboard.source)

    while True:
        import time
        time.sleep(5)
示例#2
0
def run_dashboard(window, source_class, source_kwargs):
    vehicle = Vehicle()
    dashboard = Dashboard(window, vehicle)
    dashboard.source = source_class(**source_kwargs)
    vehicle.add_source(dashboard.source)

    while True:
        import time
        time.sleep(5)
示例#3
0
def run_dashboard(window, source_class, source_kwargs):
    """Run Dashboard Routine
    @param window The window instance.
    @param The source_class instance.
    @param source_kwargs Additional input parameters."""
    vehicle = Vehicle()
    dashboard = Dashboard(window, vehicle)
    dashboard.source = source_class(**source_kwargs)
    vehicle.add_source(dashboard.source)

    while True:
        import time
        time.sleep(5)
示例#4
0
def run_dashboard(window, source_class, source_kwargs):
    vehicle = Vehicle()
    dashboard = Dashboard(window, vehicle)
    dashboard.source = source_class(**source_kwargs)
    vehicle.add_source(dashboard.source)

    window.scrollok(True)
    while True:
        c = window.getch()
        if c == curses.KEY_DOWN:
            dashboard.scroll_down(1)
        elif c == curses.KEY_UP:
            dashboard.scroll_up(1)
        elif c == curses.KEY_NPAGE:
            dashboard.scroll_down(25)
        elif c == curses.KEY_PPAGE:
            dashboard.scroll_up(25)
def run_dashboard(window, source_class, source_kwargs):
    vehicle = Vehicle()
    dashboard = Dashboard(window, vehicle)
    dashboard.source = source_class(**source_kwargs)
    vehicle.add_source(dashboard.source)

    window.scrollok(True)
    while True:
        c = window.getch()
        if c == curses.KEY_DOWN:
            dashboard.scroll_down(1)
        elif c == curses.KEY_UP:
            dashboard.scroll_up(1)
        elif c == curses.KEY_NPAGE:
            dashboard.scroll_down(25)
        elif c == curses.KEY_PPAGE:
            dashboard.scroll_up(25)
示例#6
0
class VehicleTests(unittest.TestCase):
    def setUp(self):
        super(VehicleTests, self).setUp()
        self.vehicle = Vehicle()
        self.messages_received = []

    def _callback(self, message):
        self.messages_received.append(message)

    def test_get(self):
        measurement = self.vehicle.get(TestMeasurement)
        ok_(measurement is None)

    def test_add_listener(self):
        source = TestDataSource()
        self.vehicle.add_source(source)

        self.vehicle.listen(TestMeasurement, self._callback)
        data = {'name': TestMeasurement.name, 'value': 100}
        source.inject(data)
        ok_(len(self.messages_received) > 0)

    def test_remove_listener(self):
        source = TestDataSource()
        self.vehicle.add_source(source)

        self.vehicle.listen(TestMeasurement, self._callback)
        self.vehicle.unlisten(TestMeasurement, self._callback)
        data = {'name': TestMeasurement.name, 'value': 100}
        source.inject(data)
        eq_(len(self.messages_received), 0)

    def test_get_one(self):
        source = TestDataSource()
        self.vehicle.add_source(source)
        measurement = self.vehicle.get(TestMeasurement)
        ok_(measurement is None)

        data = {'name': TestMeasurement.name, 'value': 100}
        source.inject(data)
        measurement = self.vehicle.get(TestMeasurement)
        ok_(measurement is not None)
        eq_(measurement.name, data['name'])
        eq_(measurement.value.num, data['value'])

    def test_bad_measurement_type(self):
        class NotAMeasurement(object):
            pass

        try:
            self.vehicle.get(NotAMeasurement)
        except UnrecognizedMeasurementError:
            pass
        else:
            self.fail("Expected an %s" %
                      str(UnrecognizedMeasurementError.__name__))
class VehicleTests(unittest.TestCase):
    def setUp(self):
        super(VehicleTests, self).setUp()
        self.vehicle = Vehicle()
        self.messages_received = []

    def _callback(self, message):
        self.messages_received.append(message)

    def test_get(self):
        measurement = self.vehicle.get(TestMeasurement)
        ok_(measurement is None)

    def test_add_listener(self):
        source = TestDataSource()
        self.vehicle.add_source(source)

        self.vehicle.listen(TestMeasurement, self._callback)
        data = {'name': TestMeasurement.name, 'value': 100}
        source.inject(data)
        ok_(len(self.messages_received) > 0)

    def test_remove_listener(self):
        source = TestDataSource()
        self.vehicle.add_source(source)

        self.vehicle.listen(TestMeasurement, self._callback)
        self.vehicle.unlisten(TestMeasurement, self._callback)
        data = {'name': TestMeasurement.name, 'value': 100}
        source.inject(data)
        eq_(len(self.messages_received), 0)

    def test_get_one(self):
        source = TestDataSource()
        self.vehicle.add_source(source)
        measurement = self.vehicle.get(TestMeasurement)
        ok_(measurement is None)

        data = {'name': TestMeasurement.name, 'value': 100}
        source.inject(data)
        measurement = self.vehicle.get(TestMeasurement)
        ok_(measurement is not None)
        eq_(measurement.name, data['name'])
        eq_(measurement.value.num, data['value'])

    def test_bad_measurement_type(self):
        class NotAMeasurement(object):
            pass

        try:
            self.vehicle.get(NotAMeasurement)
        except UnrecognizedMeasurementError:
            pass
        else:
            self.fail("Expected an %s" %
                    str(UnrecognizedMeasurementError.__name__))
示例#8
0
文件: PUMALog.py 项目: newyinzer/PUMA
def run_dashboard(source_class, source_kwargs):
    vehicle = Vehicle()
    dashboard = Dashboard(vehicle)
    dashboard.source = UsbVehicleInterface(callback=receive)
    #dashboard.source = source_class(**source_kwargs)
    vehicle.add_source(dashboard.source)
class VehicleTests(unittest.TestCase):
    """Vehicle Tests TestCase Class
    @author  Christopher Peplin [email protected]
    @date    June 25, 2013
    @version 0.9.4"""
    
    ## @var vehicle
    # The vehicle object instance.
    ## @var messages_received
    # The messages received instance.
    
    def setUp(self):
        """Set up Routine"""
        super(VehicleTests, self).setUp()
        self.vehicle = Vehicle()
        self.messages_received = []

    def _callback(self, message):
        """Callback Routine"""
        self.messages_received.append(message)

    def test_get(self):
        """Test Get Routine"""
        measurement = self.vehicle.get(TestMeasurement)
        ok_(measurement is None)

    def test_add_listener(self):
        """Test Add Listener"""
        source = TestDataSource()
        self.vehicle.add_source(source)

        self.vehicle.listen(TestMeasurement, self._callback)
        data = {'name': TestMeasurement.name, 'value': 100}
        source.inject(data)
        ok_(len(self.messages_received) > 0)

    def test_remove_listener(self):
        """Test Remove Listener"""
        source = TestDataSource()
        self.vehicle.add_source(source)

        self.vehicle.listen(TestMeasurement, self._callback)
        self.vehicle.unlisten(TestMeasurement, self._callback)
        data = {'name': TestMeasurement.name, 'value': 100}
        source.inject(data)
        eq_(len(self.messages_received), 0)

    def test_get_one(self):
        """Test Get One Routine"""
        source = TestDataSource()
        self.vehicle.add_source(source)
        measurement = self.vehicle.get(TestMeasurement)
        ok_(measurement is None)

        data = {'name': TestMeasurement.name, 'value': 100}
        source.inject(data)
        measurement = self.vehicle.get(TestMeasurement)
        ok_(measurement is not None)
        eq_(measurement.name, data['name'])
        eq_(measurement.value, data['value'])

    def test_bad_measurement_type(self):
        """Test Bad Measurement Type Routine"""
        try:
            self.vehicle.get(Measurement)
        except UnrecognizedMeasurementError:
            pass
        else:
            self.fail("Expected an %s" %
                    str(UnrecognizedMeasurementError.__name__))