Exemple #1
0
def con():
    hw = HardwareManager(port='virtual:./radiation_device.py')
    hw.connect_direct(1)
    con = hw.controller()
    yield con

    hw.disconnect()
Exemple #2
0
def simple_hw():

    simple_file = """{{
        "device":
        {{
            "iotile_id": "{0}",
            "trace":
            [
                [0.001, "hello "],
                [0.001, "goodbye "]
            ]
        }}
    }}
"""

    for i in [1, 3, 4, 6]:
        fname = "dev" + str(i) + ".json"
        with open(fname, 'w') as tf:
            tf.write(simple_file.format(str(i)))

    hw = HardwareManager(
        'virtual:[email protected];[email protected];[email protected];[email protected]'
    )
    yield hw

    hw.disconnect()
Exemple #3
0
def hw():
    hw = HardwareManager(port='virtual:{}'.format(path))
    hw.connect_direct(1)

    yield hw

    hw.disconnect()
    hw.close()
def tile_based():
    conf_file = os.path.join(os.path.dirname(__file__), 'tile_config.json')

    if '@' in conf_file or ',' in conf_file or ';' in conf_file:
        pytest.skip('Cannot pass device config because path has [@,;] in it')

    hw = HardwareManager('virtual:tile_based@%s' % conf_file)
    yield hw

    hw.disconnect()
Exemple #5
0
def tracer_hw():
    conf_file = os.path.join(os.path.dirname(__file__),
                             'fast_realtime_trace.json')

    if '@' in conf_file or ',' in conf_file or ';' in conf_file:
        pytest.skip('Cannot pass device config because path has [@,;] in it')

    hw = HardwareManager('virtual:realtime_test@%s' % conf_file)
    yield hw

    hw.disconnect()
Exemple #6
0
def conf2_report_hw():
    conf_file = os.path.join(os.path.dirname(__file__),
                             'report_test_config_signed.json')

    if '@' in conf_file or ',' in conf_file or ';' in conf_file:
        pytest.skip('Cannot pass device config because path has [@,;] in it')

    hw = HardwareManager('virtual:report_test@%s' % conf_file)
    yield hw

    hw.disconnect()
Exemple #7
0
def conf_ascii_tracing():
    conf_file = os.path.join(os.path.dirname(__file__),
                             'tracing_ascii_config.json')

    if '@' in conf_file or ',' in conf_file or ';' in conf_file:
        pytest.skip('Cannot pass device config because path has [@,;] in it')

    hw = HardwareManager('virtual:tracing_test@%s' % conf_file)
    hw.connect_direct('1')
    yield hw

    hw.disconnect()
def linked_tile(rpc_agent, tmpdir):
    """Create a connected HardwareManager instance with a proxy pointed at an RPCDispatcher."""

    visor, _client1, _client2 = rpc_agent

    # Create a config file that we can use to initialize a virtual device that will point at our
    # BasicRPCDispatch via a running IOTileSupervisor.  Currently, HardwareManager can only
    # load configurations for virtual devices from actual files, so we need to save this to a
    # temp file.
    config = {
        "device": {
            "iotile_id":
            1,
            "tiles": [{
                "name": "service_delegate",
                "address": 11,
                "args": {
                    "url": "ws://127.0.0.1:%d/services" % visor.
                    port,  # This has to match the port of the supervisor instance that we want to connect to
                    "service":
                    "service_1",  # This has to match the service name that the RPCDispatcher is registered as an agent for
                    "name":
                    "bsctst"  # This is the 6 character string that must match the ModuleName() of the proxy and is used to find the right proxy
                }
            }]
        }
    }

    # This is a special py.path.local object from pytest
    # https://docs.pytest.org/en/latest/tmpdir.html
    config_path_obj = tmpdir.join('config.json')
    config_path_obj.write(json.dumps(config))

    config_path = str(config_path_obj)

    reg = ComponentRegistry()
    reg.register_extension('iotile.proxy', 'test_proxy',
                           BasicRPCDispatcherProxy)

    # This will create a HardwareManager pointed at a virtual tile based device
    # where the tiles that are added to the virtual device are found using the config
    # file specified after the @ symbol.
    hw = HardwareManager(port="virtual:tile_based@%s" % config_path)  # pylint:disable=invalid-name; We use hw throughout CoreTools to denote a HardwareManager instance

    # We specified that the virtual device should be at uuid 1 (using iotile_id above)
    # so we know how to connect to it.  We also know that we specified a single tile
    # at address 11 inside that virtual device so we will be able to get its proxy
    # object by calling hw.get(11) once we are connected.
    hw.connect(1)
    yield hw

    hw.disconnect()
    reg.clear_extensions('iotile.proxy')
Exemple #9
0
def tile_based():
    conf_file = os.path.join(os.path.dirname(__file__), 'tile_config.json')

    if '@' in conf_file or ',' in conf_file or ';' in conf_file:
        pytest.skip('Cannot pass device config because path has [@,;] in it')

    reg = ComponentRegistry()
    reg.register_extension('iotile.proxy', 'vitual_tile',
                           'test/test_hw/virtual_tile.py')

    hw = HardwareManager('virtual:tile_based@%s' % conf_file)
    yield hw

    reg.clear_extensions()
    hw.disconnect()
Exemple #10
0
def inline_config_report_hw(tmpdir):
    config = {
        "device": {
            "iotile_id": "1",
            "reading_start": 0,
            "num_readings": 0,
            "stream_id": "5001",
            "format": "signed_list",
            "report_length": 0,
            "signing_method": 0
        }
    }

    config_obj = tmpdir.join("config.json")
    config_obj.write(json.dumps(config))
    config_path = str(config_obj)

    hw = HardwareManager(port="virtual:report_test@%s" % config_path)
    hw.connect(1)

    yield hw

    hw.disconnect()
Exemple #11
0
def p(tmpdir):

    path = os.path.join(os.path.dirname(__file__), 'rpc_device.py')
    config = {
        "device": {
            "tiles": [{
                "address": 10,
                "name": path,
                "args": {}
            }],
            "iotile_id": 1
        }
    }

    config_path_obj = tmpdir.join('tasks.json')
    config_path_obj.write(json.dumps(config))

    config_path = str(config_path_obj)

    hw = HardwareManager(port='virtual:tile_based@%s' % config_path)
    hw.connect_direct(1)
    tile = hw.get(10)
    yield tile
    hw.disconnect()
Exemple #12
0
def report_hw():
    hw = HardwareManager('virtual:report_test')
    yield hw

    hw.disconnect()
Exemple #13
0
def simple_hw():
    hw = HardwareManager('virtual:simple')
    yield hw

    hw.disconnect()