def basic_sg():
    """A preprogrammed basic sensorgraph for testing."""

    device = ReferenceDevice({'simulate_time': False})
    peripheral = EmulatedPeripheralTile(11, device)
    peripheral.declare_config_variable("test 1", 0x8000, 'uint16_t')
    peripheral.declare_config_variable('test 2', 0x8001, 'uint32_t[5]')

    device.add_tile(11, peripheral)

    adapter = EmulatedDeviceAdapter(None, devices=[device])

    nodes = [
        "(input 1 always) => counter 1024 using copy_latest_a",
        "(counter 1024 when count >= 1 && constant 1030 when value == 1) => counter 1030 using copy_latest_a",
        "(counter 1030 when count >= 4) => output 1 using copy_all_a"
    ]

    with HardwareManager(adapter=adapter) as hw:
        hw.connect(1)

        con = hw.get(8, basic=True)
        sensor_graph = find_proxy_plugin('iotile_standard_library/lib_controller', 'SensorGraphPlugin')(con)

        for node in nodes:
            sensor_graph.add_node(node)

        sensor_graph.add_streamer('output 10', 'controller', True, 'individual', 'telegram')

        yield sensor_graph, hw, device
Exemple #2
0
def basic_device():
    """A preprogrammed basic sensorgraph for testing."""

    device = ReferenceDevice({'simulate_time': False})
    adapter = EmulatedDeviceAdapter(None, devices=[device])

    nodes = [
        "(system input 2 always) => output 1 using copy_latest_a",
        "(system input 3 always) => output 2 using copy_latest_a",
        "(system input 5 always) => output 3 using copy_latest_a",
        "(system input 6 always) => output 4 using copy_latest_a"
    ]

    with HardwareManager(adapter=adapter) as hw:
        hw.connect(1)

        con = hw.get(8)
        sensor_graph = con.sensor_graph()

        for node in nodes:
            sensor_graph.add_node(node)

        sensor_graph.add_streamer('output 10', 'controller', True, 'individual', 'telegram')

        yield hw, device
def reference_hw():
    """Get a reference device and connected HardwareManager."""

    device = ReferenceDevice({'simulate_time': False})
    peripheral = EmulatedPeripheralTile(11, device)
    peripheral.declare_config_variable("test 1", 0x8000, 'uint16_t')
    peripheral.declare_config_variable('test 2', 0x8001, 'uint32_t[5]')

    device.add_tile(11, peripheral)

    adapter = EmulatedDeviceAdapter(None, devices=[device])

    with HardwareManager(adapter=adapter) as hw:
        hw.connect(1)

        yield hw, device, peripheral
def streaming_sg():
    """A preprogrammed basic sensorgraph for testing streaming."""

    device = ReferenceDevice({'simulate_time': False})

    adapter = EmulatedDeviceAdapter(None, devices=[device])

    nodes = [
        "(input 1 when count >= 1) => output 1 using copy_latest_a",
        "(input 2 when count >= 1) => output 2 using copy_latest_a",
        "(input 3 when count >= 1 && constant 1 always) => unbuffered 1 using trigger_streamer"
    ]

    with HardwareManager(adapter=adapter) as hw:
        hw.connect(1)

        con = hw.get(8, basic=True)
        sensor_graph = find_proxy_plugin('iotile_standard_library/lib_controller', 'SensorGraphPlugin')(con)

        for node in nodes:
            sensor_graph.add_node(node)

        sensor_graph.push_reading('constant 1', 0)

        sensor_graph.add_streamer('output 1', 'controller', False, 'individual', 'telegram')
        sensor_graph.add_streamer('output 2', 'controller', False, 'hashedlist', 'telegram', withother=0)

        yield sensor_graph, hw, device
Exemple #5
0
def basic_device():
    """A preprogrammed basic sensorgraph for testing."""

    device = ReferenceDevice({})
    adapter = EmulatedDeviceAdapter(None, devices=[device])

    nodes = [
        "(system input 2 always) => output 1 using copy_latest_a",
        "(system input 3 always) => output 2 using copy_latest_a",
        "(system input 5 always) => output 3 using copy_latest_a",
        "(system input 6 always) => output 4 using copy_latest_a"
    ]

    with HardwareManager(adapter=adapter) as hw:
        hw.connect(1)

        con = hw.get(8, basic=True)
        sensor_graph = find_proxy_plugin(
            'iotile_standard_library/lib_controller', 'SensorGraphPlugin')(con)

        for node in nodes:
            sensor_graph.add_node(node)

        sensor_graph.add_streamer('output 10', 'controller', True,
                                  'individual', 'telegram')

        yield hw, device
def test_peripheral_tiles():
    """Make sure the controller tile properly brings up the peripheral tiles in a controlled manner."""

    # Don't use the fixture since the purpose of this test is to make sure the fixture works
    device = ReferenceDevice({'simulate_time': False})
    peripheral = EmulatedPeripheralTile(10, device)
    device.add_tile(10, peripheral)

    device.start()
    device.stop()
def reference():
    """Get a reference device with a controller and single peripheral tile."""

    device = ReferenceDevice({'simulate_time': False})
    peripheral = EmulatedPeripheralTile(10, device)
    device.add_tile(10, peripheral)

    device.start()
    yield device, peripheral
    device.stop()
def sg_device():
    """Get a reference device and connected HardwareManager."""

    device = ReferenceDevice({'simulate_time': False})
    peripheral = EmulatedPeripheralTile(11, device)
    peripheral.declare_config_variable("test 1", 0x8000, 'uint16_t')
    peripheral.declare_config_variable('test 2', 0x8001, 'uint32_t[5]')

    device.add_tile(11, peripheral)

    adapter = EmulatedDeviceAdapter(None, devices=[device])

    with HardwareManager(adapter=adapter) as hw:
        hw.connect(1)

        con = hw.get(8, basic=True)
        sensor_graph = find_proxy_plugin('iotile_standard_library/lib_controller', 'SensorGraphPlugin')(con)

        yield sensor_graph, hw
def sg_device():
    """Get a reference device and connected HardwareManager."""

    device = ReferenceDevice({'simulate_time': False})
    peripheral = EmulatedPeripheralTile(11, device)
    peripheral.declare_config_variable("test 1", 0x8000, 'uint16_t')
    peripheral.declare_config_variable('test 2', 0x8001, 'uint32_t[5]')

    device.add_tile(11, peripheral)

    adapter = EmulatedDeviceAdapter(None, devices=[device])

    with HardwareManager(adapter=adapter) as hw:
        hw.connect(1)

        con = hw.get(8, basic=False)
        sensor_graph = con.sensor_graph()

        yield sensor_graph, hw
def empty_sg():
    """An empty sensorgraph for testing."""

    device = ReferenceDevice({'simulate_time': False})

    adapter = EmulatedDeviceAdapter(None, devices=[device])

    with HardwareManager(adapter=adapter) as hw:
        hw.connect(1)

        con = hw.get(8, basic=False)
        sensor_graph = con.sensor_graph()
        yield sensor_graph, hw, device