Config

ConfigHandler

class Config.ConfigHandler.ConfigHandler(config_file_name)[source]
Description

Base class for handling *.ini configs.

Parameters

config_file_name (str, optional) – Name of config file.

Raises
  • ValueError

    – Config file name does not end with ‘.ini’.

    – Config file name contains disallowed symbols.

  • FileNotFoundError – Config file with given name does not exist.

static check_config_file(config_file_name)[source]
Description

Check if config file exists and name ends with ‘.ini’ and contains only allowed symbols A-Z, a-z ,0-9.

Parameters

config_file_name (str) – Name of config file.

Raises
  • ValueError

    – Config file name does not end with ‘.ini’.

    – Config file name contains disallowed symbols.

  • FileNotFoundError – Config file with given name does not exist.

save_config()[source]
Description

Save updated config.

setup_config()[source]
Description

Load config and save number of config sections.

Can Config

CanConfigHandler

class Config.CanBus.CanConfigHandler.CanConfigHandler(config_file_name='can_config.ini')[source]
Inherit

ConfigHandler

Description

Main task is to handle CAN config file.

Can load config and return it as a list of CanDataConfig objects, or update config sections from given CanDataConfig object.

Parameters

config_file_name (str) – Name of config file.

Raises

For error handling see base class ConfigHandler.

static check_config_id(config_id)[source]
Description

Check type and value of config id that is supposed to be loaded

Raises
  • TypeError – Config id is not an integer.

  • ValueError – Config id is not in range of existing config sections.

static check_update_parameter_type(data_config)[source]
Description

Check type of data config

Raises

TypeError – Parameter data_config is not a CanDataConfig type.

load_from_config_file()[source]
Description

Load every section saved in config file to list of DataConfig objects.

Returns

List of DataConfig object.

Return type

list[CanDataConfig]

load_selected_from_config_file(config_id)[source]
Description

Load selected section from config file.

Section is selected by unique id.

Parameters

config_id (int) – Id of data config section.

Returns

data in form of object DataConfig for selected configuration

Return type

CanDataConfig

Raises
  • TypeError – Config id is not an integer.

  • ValueError – Config id is not in range of existing config sections.

update_section_in_config(data_config)[source]
Description

Update config section with new config for already existing section.

Automatically save changes to file.

Parameters

data_config (CanDataConfig) – Updated section config

Raises

TypeError – Parameter data_config is not a CanDataConfig type.

CanDataConfig

class Config.CanBus.CanDataConfig.CanDataConfig(id, group_id, widget_id, overview_id, name, unit, can_id, start_bit, length, multiplier, offset, endian)[source]
Description

This class contains data configuration.

Parameters
  • id (int) – Unique id.

  • group_id (int) – Id of display group in UI.

  • group_id – Id of widget in display group.

  • overview_id (int) – Id of widget in overview tab.

  • name (str) – Name of variable.

  • unit (str) – Unit type of value (°C, Km/h, …)

  • can_id (str) – Id of can message.

  • start_bit (int) – Bit on which data starts.

  • length (int) – Number of bits to read starting from start bit.

  • multiplier (float, int) – Multiplier for data bounded with start bit and length.

  • offset (float, int) – Offset of value gained from bounded data with start bit and length.

  • endian (str) – Type of endian (Little, Big).

Raises
  • TypeError

    – Id is not an integer.

    – Group id is not an integer.

    – Widget id is not an integer.

    – Overview id is not an integer.

    – Name is not a str.

    – Unit is not a str.

    – Can_id is not a hex string.

    – Start bit is not an integer.

    – Length bit is not an integer.

    – Multiplier is not an integer or float.

    – Offset is not an integer or float.

    – Endian is not a str.

  • ValueError

    – Group id is not in range 0 - 20.

    – Widget id is not in range 1 - 50.

    – Overview id is not in range 1 - 50.

    – Can_id is hex string longer then 8.

    – Start bit is not in range 0 - 63.

    – Length is not in range 1 - 63.

    – Multiplier is equal to 0.

    – Endian is not a “L” or “B”.

Serial Config

ComConfigHandler

class Config.Communication.ComConfigHandler.ComConfigHandler(config_file_name='communication_config.ini')[source]
Inherit

ConfigHandler

Description

Main task is to handle Com config file.

Parameters

config_file_name (str, optional) – Name of config file.

Raises

For error handling see base class ConfigHandler.

load_serial_info()[source]
Description

Load current serial com config.

Returns

load_wifi_info()[source]
Description

Load current Wi-Fi com config.

Returns

update_serial_info(port, baud_rate)[source]
Description

Update serial com config.

Parameters
  • port (str) – Name of com port.

  • baud_rate (int) – Desired baud rate.

update_wifi_info(ip, port)[source]
Description

Update Wi-Fi com config.

Parameters
  • ip (str) – Ip address of remote device.

  • port (int) – Port on which devices will communicate.