Configuration File
Configuration files, commonly known as .ini files, are used to set setup-specific parameters for a SweepMe! driver that only need to be defined once. Some drivers require information on the paths to installed drivers, SDKs, or .dll files, other drivers might need access keys or version numbers, which only need to be set once after installation.
Where the configuration file is located
A driver reads its configuration file only from the folder CustomFiles of the public SweepMe! folder, i.e. %PUBLIC%\Documents\SweepMe!\CustomFiles (usually C:\Users\Public\Documents\SweepMe!\CustomFiles). The file must have the same name as the driver folder, e.g. Switch-Thorlabs_FW102C.ini. A configuration file that is shipped inside the driver folder is only a template. Changes to the template have no effect.
Do not confuse the configuration file with other .ini files inside a driver folder, such as config.ini or info.ini. These files contain information for SweepMe! about the driver and must not be edited by users.
Setting Up Your Configuration File
If a driver comes with a configuration file template, follow these steps:
- Launch SweepMe!.
- Open Tools → Version Manager (Version manager in version 1.5) and search for your driver.
- Right-click on the version number to open the context menu.
- Choose Copy configuration (.ini) file to 'CustomFiles' to copy the template to the folder CustomFiles. If the file already exists there, SweepMe! asks whether to overwrite it.
- Edit the file:
- From version 1.5.6.20, choose Edit configuration (.ini) file in the same context menu. If the file does not exist in CustomFiles yet, it is copied there first.
- Alternatively, open the folder %PUBLIC%\Documents\SweepMe!\CustomFiles in the Windows Explorer and edit the .ini file with any text editor.
- Save the file.
If a driver does not offer these menu entries, create the file yourself in the folder CustomFiles with the name of the driver folder and the sections and keys described in the documentation of the driver.
Examples of Typical Parameters
Here are examples of typical parameters that you might set in your .ini file:
Path to an Installed Driver, SDK, or .dll file
[Awesome Device]
sdk_path = C:\Program Files\Awesome Device\Awesome SDK 2.1
dlls =
C:\Program Files\Awesome Device\file1.dll
C:\Program Files\Awesome Device\file2.dll
Device Parameters
[Filter]
Filter1 = 1 <- 400 nm -> 2 <- 700 nm -> 3 <- 750 nm -> 4 <- 800 nm -> 5
[Lamp]
Lamp1 = Halogen
Lamp2 = Xenon
Lamp3 = Xenon <- 600 nm -> Halogen
Reading the configuration in a driver
Drivers can read their configuration file with the following functions of the driver class (see Driver Programming):
# dictionary with all key-value pairs of one section, empty if the file or the section does not exist
options = self.get_configoptions("Awesome Device")
sdk_path = options.get("sdk_path", "")
# list of all section names
sections = self.get_configsections()
# nested dictionary with a dictionary of key-value pairs for each section
config = self.get_config()
All values are returned as strings. Keys are returned in lower case, e.g. Filter1 becomes filter1.