Skip to content

Manage Configuration

A hardware configuration describes the set of devices, drivers, and library paths that define an Inscoper system. The API provides two distinct operations for interacting with a configuration file: loading it to initialize the hardware, and reading it to inspect its contents without activating any devices.

Overview

The two operations serve different purposes:

Operation Method Effect
Load loadConfigFile() followed by initDevices() Parses the configuration, establishes communication with the hardware, and places the system in a ready state
Read readConfigFile() Parses the configuration and returns a configuration object without initializing any devices

Use load when the intent is to control hardware. Use read when the intent is to inspect or validate the configuration — for example, to enumerate devices before deciding which to activate.


Load a configuration

Load a configuration file by name and initialize all declared devices. An optional call to setLibraryPaths() allows specifying additional directories from which device driver libraries are resolved, which is necessary if drivers are located outside the default search paths.

import inscoper_api

bridge = inscoper_api.Bridge()

bridge.setLibraryPaths(["external/lib/folder/path/1", "external/lib/folder/path/2"])
bridge.loadConfigFile("configuration/folder/path")
bridge.initDevices()

Read a configuration

Read a configuration file without initializing any devices. The returned configuration object provides access to the device list, the list of registered driver directories, and the list of drivers declared in the file.

import inscoper_api
import os

# Macro to all Inscoper configurations
CONFIG_PATH = os.environ['InscoperConfigsPath']

my_bridge = inscoper_api.Bridge()

config = my_bridge.readConfigFile(os.sep.join([CONFIG_PATH, "singleCamera"]))

print("List of devices:", [device.getId() for device in config.getDeviceList()])
print("List of driver folders:", config.getLibraryPaths())
print("List of drivers:", config.getDriverList())

my_bridge.close()