Data reception and handling

class DataReceiver(dataInterface: SerialDataInterface)

Class which receives the measurement data from the device.

The device tries to send the data during the measurement, but if not all measurement points could be sent live, they are sent afterwards and then sorted into the live measurement points. Live data and online data means the same.

If several primitives are measured one after the other, the date will be appended further and further to the old data. The primitives always start again at time 0 but at this time there is no measurement result yet. Only at the time 0 plus sampling period there is the first measuring point.

This class recalculates the time axis if the primitives were measured one after the other. The dead time at the end of the measurement if complete data must be transmitted is not visible in the time axis, since here is not measured.

The complete protocol documentation is available on request. This implementation is sufficient for normal operation.

The examples and the example online display are the easiest way to learn how to use this class to get the data from the measuring device. Examples are in datahandler.py. There the data are read from the object.

The following is an example of the data structure: {”TrackTypes.TIME” : [1, 2, 3, 4] , “TrackTypes.VOLTAGE” : [3, 2, 3, 4] , “TrackTypes.CURRENT” : [0, 2, 3, 0]}

Parameters

dataInterface (SerialDataInterface) – Data interface to the device.

stop() None

Stop the data receiver and close.

This method stops the internal threads and closes the interface.

getNumberOfCompleteAndOnlinePoints() int

Get the number of received points.

Returns the number of measurement points which are complete and which were received live. After the end of a primitive, live data becomes complete data.

Returns

Number of measurement points.

getNumberOfCompletePoints() int

Get the number of received complete data.

Returns the number of measurement points which are complete. Thus completed finished primitive. After the end of a primitive, live data becomes complete data.

Returns

Number of measurement points.

getNumberOfOnlinePoints() int

Get the number of received live points.

Returns the number of measurement points which are complete and which were received live. After the end of a primitive, live data becomes complete data.

Returns

Number of measurement points.

getTrackTypeList() list[zahner_potentiostat.scpi_control.datareceiver.TrackTypes]

List of track types that are currently being processed.

At the moment with the PP2x2 and XPOT2 devices there is only voltage, current and time.

Returns

Number of measurement points.

getCompleteTrack(track: Union[TrackTypes, int], minIndex: int = 0, maxIndex: Optional[int] = None) list[float]

Retrieves points to a completed data track.

Parameters
  • track – Track as string, number or TrackTypes.

  • minIndex – By default 0, this means from 0.

  • maxIndex – By default 0, this means to the end.

Returns

An array with the data for the track. Each returned data point consists of a dictionary with the track names.

getOnlineTrack(track: Union[TrackTypes, int], minIndex: int = 0, maxIndex: Optional[int] = None) list[float]

Retrieves points to a online/live data track.

Parameters
  • track – Track as string, number or TrackTypes.

  • minIndex – By default 0, this means from 0.

  • maxIndex – By default 0, this means to the end.

Returns

An array with the data for the track. Each returned data point consists of a dictionary with the track names.

getCompletePoints(minIndex: int = 0, maxIndex: Optional[int] = None) dict[str, list[float]]

Retrieves points to all data tracks for completed data.

Parameters
  • minIndex – By default 0, this means from 0.

  • maxIndex – By default None, this means to the end.

Returns

An array with the data for the track. Each returned data point consists of a dictionary with the track names.

getOnlinePoints(minIndex: int = 0, maxIndex: Optional[int] = None) dict[str, list[float]]

Retrieves points to all data tracks for online/live data.

Parameters
  • minIndex – By default 0, this means from 0.

  • maxIndex – By default None, this means to the end.

Returns

An array with the data for the track. Each returned data point consists of a dictionary with the track names.

getCompleteAndOnlinePoints() dict[str, list[float]]

Retrieves points to all data tracks for completed and online data.

Returns

An array with the data for the track. Each returned data point consists of a dictionary with the track names.

deletePoints()

Delete the received complete points.

_receiveDataThread() None

Receive thread which calls the individual decoders for the different packets.

_processDataLight(length: int) None

Process packet type DataLight

_processDataLightBulk(length: int) None

Process packet type DataLightBulk

_sortOnlineDataByTrack(trackType: TrackTypes) None

Sort the online data.

Sorting the data according to one of the data tracks.

Parameters

trackType (TrackTypes) –

_processDataLightBulkAppendum(length: int) None

Process packet type DataLightBulkAppendum.

This data must then be sorted into the online data.

_processMeasurementHeader(length: int) None

Process packet type MeasurementHeader

_processMeasurementTracks(length: int) None

Process packet type MeasurementTracks

_readU64() int

Read unsigned 64 bit integer from the interface.

Returns

The read value.

_readF64() float

Read 64 bit floating point from the interface.

Returns

The read value.

_readString() str

Read a string from the interface.

Returns

The read string.

_clearOnlineData() None

Clear the received online data.

_onlineDataToCompleteData() None

Transfer online to complete data.

enum TrackTypes(value)

Enumeration with the different types for the data tracks.

Valid values are as follows:

TIME = <TrackTypes.TIME: 13>
CURRENT = <TrackTypes.CURRENT: 12>
VOLTAGE = <TrackTypes.VOLTAGE: 11>

The Enum and its members also have the following methods:

classmethod numberToTrack(number: int) Self

Convert a number to the TrackType.

Parameters

number – The number of the Track.

Returns

The specific Track as TrackTypes Type.

classmethod stringToTrack(string: str) Self

Convert a string to the TrackType.

Parameters

string – The Track as string of the Track.

Returns

The specific Track as TrackTypes Type.

toString() str

Convert the TrackTypes Type to a String.

Returns

The TrackTypes Type as String.

enum PacketTypes(value)

Enumeration with the numbers of the different package types.

Valid values are as follows:

DATALIGHT = <PacketTypes.DATALIGHT: 18369578673207648802>
DATALIGHTBULK = <PacketTypes.DATALIGHTBULK: 18369578673780311108>
DATALIGHTBULKAPPENDUM = <PacketTypes.DATALIGHTBULKAPPENDUM: 18369578674639304567>
MEASUREMENTHEADER = <PacketTypes.MEASUREMENTHEADER: 12684370814423863569>
MEASUREMENTTRACKS = <PacketTypes.MEASUREMENTTRACKS: 12528433677326160145>
enum MeasurementTypes(value)

Enumeration with known standard measurements.

Valid values are as follows:

IE = <MeasurementTypes.IE: 5>
TIU = <MeasurementTypes.TIU: 21>
enum HeaderState(value)

Enumeration with status numbers of the header.

Valid values are as follows:

PENDING = <HeaderState.PENDING: 0>
START = <HeaderState.START: 1>
RUNNING = <HeaderState.RUNNING: 2>
DONE = <HeaderState.DONE: 3>
FINISHING = <HeaderState.FINISHING: 4>
ABORTED = <HeaderState.ABORTED: 5>
CANCELLED = <HeaderState.CANCELLED: 6>