Data Processing

DataPoint

class DataProcessing.DataPoint.DataPoint(id, group_id, overview_id, name, value)[source]
Description

This Class contains data information like name, value, id, group id and overview id.

Containing data are being used to update values in graphical interface.

Parameters
  • id (int) – Id of widget in display group

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

  • name (str) – Name of variable

  • value (float, int) – Real value.

Raises
  • TypeError

    – Widget id is not an integer.

    – Overview id is not an integer.

    – Group id is not an integer.

    – Name is not a str.

    – Value is not a float or int.

  • ValueError

    – Widget id is not in range 1 - 50.

    – Overview id is not in range 1 - 50.

    – Group id is not in range 0 - 20.

DataProcessing

class DataProcessing.DataProcessing.DataProcessing(can_id, can_data, config_list)[source]
Description

This class takes ID, binary data and list of configs as input.

Main task is to decode and processed binary data based on given config list.

Resulting object will contain information like name, value, id and group id.

Parameters
  • can_id (str) – Id of CAN message

  • can_data (str) – CAN message in binary format

  • config_list (list[CanDataConfig]) – List of data configurations

Raises
  • TypeError

    – Can_id is not a hex string.

    – Data is not a binary str.

  • ValueError

    – Can_id is hex string longer then 8.

    – Can_data does not have length of 8 bytes (64 bits).

data_decode()[source]
Description

Checks if there are data configurations for given can id.

If so call processed data for each configuration where conf can id == given can id.

As result return list of DataPoints, containing useful information as widget id, group id, name, value, etc.

Returns

List of DataPoints

Return type

list[DataPoint]

static data_process(bin_data, data_config)[source]
Description

Takes binary data and suitable data configuration as input.

Based on given configuration processed data -> convert data from binary to real value.

Conversion is done as follows:
  1. Convert bin data to int in right format (Little or Big endian)

  2. Multiply data by configuration multiplier

  3. Add configuration offset

Parameters
  • bin_data (str) – Can data in binary format.

  • data_config (CanDataConfig) – Suitable configuration

Returns

Real value processed by given configuration

Return type

float

DataProcessingManager

class DataProcessing.DataProcessingManager.DataProcessingManager(received_data, data_config_list)[source]
Inherit

QRunnable

Description

This class inherit from QRunnable -> can run as separate task.

Takes care of data processing flow.

Data to superior task are being passed with Qt Signal.

Parameters
  • received_data (bytearray) – Received data in raw format.

  • data_config_list (list[CanDataConfig]) – List of data configurations

run()[source]
Description
Runs data processing sequence:
  1. Split received data to ID and Data.

  2. Decode and processed data based on configuration.

  3. Send data to superior task with QtSignal

class DataProcessing.DataProcessingManager.DataSignal[source]
Inherit

QObject

Description

Helper class for DataProcessingManager allowing usage of Qt Signal.

RawData

class DataProcessing.RawData.RawData(raw_data)[source]
Description

This class takes raw received data from remote device.

Used to split raw data into ID and data part.

Parameters

raw_data (bytearray) – Received data from remote device in its raw format.

Raises
split_data()[source]
Description

Split ID and data part from raw_data.

Data will be returned in binary code with fixed length 64 bit.

Returns

  • ID (int)

  • Data (str) -> (in python bin is str with leading ‘0b’)