Contents

class TMSiSDK.device.devices.apex.apex_device.ApexDevice(serial_number, dr_interface: DeviceInterfaceType, pairing_status=PairingStatus.no_pairing_needed, dongle_serial_number=0, idx=-1)#

Bases: TMSiDevice

A class to represent and handle the Apex

__init__(serial_number, dr_interface: DeviceInterfaceType, pairing_status=PairingStatus.no_pairing_needed, dongle_serial_number=0, idx=-1)#

Initialize the Device.

Parameters:
  • dr_serial_number (int) – Serial number of the device.

  • dr_interface (DeviceInterfaceType) – Interface to use to communicate with the device.

  • pairing_status (PairingStatus, optional) – pairing status, defaults to PairingStatus.no_pairing_needed

  • dongle_serial_number (int) – Serial number of the dongle, default to 0.

  • idx (int, optional) – Device index, defaults to -1.

Methods

__init__(serial_number, dr_interface[, ...])

Initialize the Device.

close()

Closes the connection to the device.

discover([num_retries])

Discovers available devices.

download_file_from_device(file_id[, filename])

Creates a data stream to download the file from the device.

export_configuration(filename)

Exports the current configuration to an xml file.

get_card_recording_config()

Gets configuration for card recording.

get_card_status()

Gets card status.

get_device_active_channels()

Gets the list of active channels.

get_device_active_impedance_channels()

Gets the list of active impedance channels.

get_device_card_file_info(file_id)

Gets the information of the file on the device's card.

get_device_card_file_list()

Gets the list of files available on the device's card.

get_device_channels()

Gets the list of channels.

get_device_data(POINTER_received_data_array, ...)

Gets data from the device during sampling.

get_device_handle_value()

Returns the value of the device handle.

get_device_impedance_channels()

Gets the list of impedance channels.

get_device_impedance_data(...)

Gets impedance data from the device during sampling.

get_device_info_report()

Gets the report with device information.

get_device_interface_status([interface])

Gets the device interface status.

get_device_list()

Gets the list of available devices.

get_device_name()

Get name of the device

get_device_power_status()

Returns the power status of the device

get_device_sampling_config()

Gets the sampling configuration of the device.

get_device_sampling_frequency([detailed])

Gets the sampling frequency.

get_device_serial_number()

Gets the serial number of the device.

get_device_state()

Gets the state of the device.

get_device_time()

Gets the time on the device.

get_device_type()

Returns the device type.

get_dongle_list()

Returns the list of available dongles.

get_dongle_serial_number()

Gets the serial number of the dongle.

get_downloaded_percentage()

Gets the percentage of file downloaded.

get_dr_interface()

Returns the interface of the device.

get_driver_version()

Gets the version of the DLL and USB drivers.

get_event()

Gets the last event available

get_event_buffer()

Gets the available events in the buffer

get_file_channels(file_id)

Gets the list of channels from the file.

get_id()

Gets the device id.

get_live_impedance()

Returns if live impedance is enabled.

get_num_active_channels()

Returns the number of active channels of the device.

get_num_active_impedance_channels()

Returns the number of active impedance channels of the device.

get_num_channels()

Returns the number of channels of the device.

get_num_impedance_channels()

Returns the number of impedance channels of the device.

get_pairing_status()

Returns the pairing status of the device.

get_sdk()

Gets the handle of the communication library

import_configuration(filename)

Imports the file configuration to the device.

open([dongle_id])

Opens the connection with the device.

pair_device(device_id)

Pairs the device with the dongle

reload_device()

Reload information from device

reset_device_card()

Resets the memory card of the device.

reset_device_data_buffer()

Resets the incoming buffer.

reset_device_event_buffer()

Resets the incoming event buffer.

reset_to_factory_default()

Resets the device to default configuration.

set_card_recording_config(config)

Sets the configuration for recording on card.

set_device_channel_names(names, indices)

Sets the device channel names

set_device_download_file_request(file_request)

Sets the download file request to start or stop the download stream.

set_device_impedance_request(measurement_request)

Sets the impedance request to start or stop the acquisition.

set_device_interface([device_interface, control])

Set the device interface.

set_device_references(list_references, ...)

Sets the channels to be used as reference.

set_device_sampling_config([...])

Sets the sampling configuration of the device.

set_device_sampling_request(measurement_request)

Sets the sampling request to start or stop the acquisition.

set_device_time(datetime)

Sets the datetime of the device.

start_download_file(file_id[, filename, ...])

Starts the download of the file requested.

start_measurement(measurement_type[, ...])

Starts the measurement requested.

stop_download_file()

Stops the download of the file.

stop_measurement()

Stops the measurement requested.

user_abort_download()

Interrupts the download after user abort command.

close()#

Closes the connection to the device.

Raises:
  • TMSiError – TMSiErrorCode.device_error if impossible to close.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

discover(num_retries: int = 3)#

Discovers available devices.

Parameters:
  • dr_interface (DeviceInterfaceType) – Device interface to be searched. Allowed interfaces: usb and bluetooth.

  • num_retries – Number of retries, optional

download_file_from_device(file_id: int, filename: str = None)#

Creates a data stream to download the file from the device.

Parameters:
  • file_id (int) – id of the file to download.

  • filename (str, optional) – filename where to write the impedance report (if available), defaults to None

Raises:
  • TMSiError – TMSiErrorCode.file_writer_error if impedance report download fails.

  • TMSiError – TMSiErrorCode.device_error if the file download fails.

  • TMSiError – TMSiErrorCode.api_invalid_command if already sampling.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

export_configuration(filename: str)#

Exports the current configuration to an xml file.

Parameters:

filename (str) – name of the file where to export configuration.

Raises:
  • TMSiError – TMSiErrorCode.file_writer_error if export configuration fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

get_card_recording_config() TMSiDevCardRecCfg#

Gets configuration for card recording.

Raises:
  • TMSiError – TMSiErrorCode.device_error if get configuration fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

Configuration of the card recording.

Return type:

TMSiDevCardRecCfg

get_card_status() TMSiDevCardStatus#

Gets card status.

Raises:
  • TMSiError – TMSiErrorCode.device_error if get card status fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

Configuration of the card recording.

Return type:

TMSiDevCardStatus

get_device_active_channels() list#

Gets the list of active channels.

Raises:
  • TMSiError – TMSiErrorCode.device_error if get channels from the device fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

The list of channels

Return type:

list[ApexChannel]

get_device_active_impedance_channels() list#

Gets the list of active impedance channels.

Raises:
  • TMSiError – TMSiErrorCode.device_error if get channels from the device fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

The list of channels

Return type:

list[ApexImpedanceChannel]

get_device_card_file_info(file_id: int) tuple#

Gets the information of the file on the device’s card.

Parameters:

file_id (int) – Id of the file to be investigated.

Raises:
  • TMSiError – TMSiErrorCode.device_error if get card info fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

A tuple with file metadata and file details.

Return type:

tuple[TMSiFileMetadataHeader, TMSiDevCardFileDetails]

get_device_card_file_list() list#

Gets the list of files available on the device’s card.

Raises:
  • TMSiError – TMSiErrorCode.device_error if get card file list fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

A list of file info.

Return type:

list[TMSiDevCardFileInfo]

get_device_channels() list#

Gets the list of channels.

Raises:
  • TMSiError – TMSiErrorCode.device_error if get channels from the device fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

The list of channels

Return type:

list[ApexChannel]

get_device_data(POINTER_received_data_array: pointer, buffer_size: int, POINTER_num_of_sets: pointer, POINTER_data_type: pointer) TMSiDeviceRetVal#

Gets data from the device during sampling.

Parameters:
  • POINTER_received_data_array (pointer(array[c_float])) – array that will contain the received data.

  • buffer_size (int) – maximum size of the buffer.

  • POINTER_num_of_sets (pointer(c_uint)) – number of sets of data received.

  • POINTER_data_type (pointer(c_int)) – type of data received.

Raises:

TMSiError – TMSiErrorCode.api_invalid_command if device is not in sampling mode

Returns:

return value of the call

Return type:

TMSiDeviceRetVal

get_device_handle_value() int#

Returns the value of the device handle.

Returns:

Device handle.

Return type:

int

get_device_impedance_channels() list#

Gets the list of impedance channels.

Raises:
  • TMSiError – TMSiErrorCode.device_error if get channels from the device fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

The list of channels

Return type:

list[ApexImpedanceChannel]

get_device_impedance_data(POINTER_received_data_array: pointer, buffer_size: int, POINTER_num_of_sets: pointer) TMSiDeviceRetVal#

Gets impedance data from the device during sampling.

Parameters:
  • POINTER_received_data_array (pointer(array[TMSiImpedanceSample])) – array that will contain the received data.

  • buffer_size (int) – maximum size of the buffer.

  • POINTER_num_of_sets (pointer) – number of sets of data received.

Raises:

TMSiError – TMSiErrorCode.api_invalid_command if device is not in sampling mode

Returns:

return value of the call

Return type:

TMSiDeviceRetVal

get_device_info_report() TMSiDevInfoReport#

Gets the report with device information.

Raises:
  • TMSiError – TMSiErrorCode.device_error if get device info from the device fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

the device info report.

Return type:

TMSiDevInfoReport

get_device_interface_status(interface=DeviceInterfaceType.bluetooth) TMSiInterfaceStatus#

Gets the device interface status.

Parameters:

interface (DeviceInterfaceType, optional) – interface to check, defaults to DeviceInterfaceType.bluetooth

Raises:
  • TMSiError – TMSiErrorCode.device_error if get device interface status from the device fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

interface status of the device.

Return type:

TMSiInterfaceStatus

get_device_list() list#

Gets the list of available devices.

Parameters:

dr_interface (DeviceInterfaceType) – interface to check.

Returns:

a list of available devices on the requested interface.

Return type:

list[ApexDevice]

get_device_name()#

Get name of the device

Returns:

name of the device

Return type:

str

get_device_power_status() TMSiDevPowerStatus#

Returns the power status of the device

Raises:
  • TMSiError – TMSiErrorCode.device_error if get device power status from the device fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

device power status.

Return type:

TMSiDevPowerStatus

get_device_sampling_config() TMSiDevSamplingCfg#

Gets the sampling configuration of the device.

Raises:
  • TMSiError – TMSiErrorCode.device_error if get device sampling configuration from the device fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

device sampling configuration

Return type:

TMSiDevSamplingCfg

get_device_sampling_frequency(detailed=False) int#

Gets the sampling frequency.

Parameters:

detailed (bool, optional) – detailed frequency description, defaults to False

Returns:

sampling frequency or frequencies.

Return type:

int or dictionary if detailed

get_device_serial_number() int#

Gets the serial number of the device.

Returns:

serial number of the device.

Return type:

int

get_device_state() DeviceState#

Gets the state of the device.

Returns:

the device state.

Return type:

DeviceState

get_device_time() datetime#

Gets the time on the device.

Raises:
  • TMSiError – TMSiErrorCode.device_error if get time from the device fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

returns the datetime on the device.

Return type:

datetime.datetime

get_device_type() str#

Returns the device type.

Returns:

the device type.

Return type:

str

get_dongle_list() list#

Returns the list of available dongles.

Returns:

list of available dongles.

Return type:

list[ApexDongle]

get_dongle_serial_number() int#

Gets the serial number of the dongle.

Returns:

serial number of the device.

Return type:

int

get_downloaded_percentage() int#

Gets the percentage of file downloaded.

Returns:

percentage of file downloaded.

Return type:

int

get_dr_interface() DeviceInterfaceType#

Returns the interface of the device.

Returns:

the interface of the device.

Return type:

DeviceInterfaceType

get_driver_version() tuple#

Gets the version of the DLL and USB drivers.

Raises:

TMSiError – TMSiErrorCode.device_error if it fails.

Returns:

tuple(dll_version, usb_version)

Return type:

tuple(str, str)

get_event()#

Gets the last event available

Parameters:

POINTER_event (TMSiEvent) – pointer to the event structure to fill.

get_event_buffer()#

Gets the available events in the buffer

Returns:

TMSiDeviceRetVal

Return type:

TMSiDeviceRetVal

get_file_channels(file_id)#

Gets the list of channels from the file.

Parameters:

file_id (int) – id of the file

Returns:

The list of channels

Return type:

list[ApexChannel]

get_id() int#

Gets the device id.

Returns:

the device id.

Return type:

int

get_live_impedance() bool#

Returns if live impedance is enabled.

Returns:

True if enabled, False if disabled.

Return type:

bool

get_num_active_channels() int#

Returns the number of active channels of the device.

Returns:

number of active channels of the device.

Return type:

int

get_num_active_impedance_channels() int#

Returns the number of active impedance channels of the device.

Returns:

number of active impedance channels of the device.

Return type:

int

get_num_channels() int#

Returns the number of channels of the device.

Returns:

number of channels of the device.

Return type:

int

get_num_impedance_channels() int#

Returns the number of impedance channels of the device.

Returns:

number of impedance channels of the device.

Return type:

int

get_pairing_status()#

Returns the pairing status of the device.

Returns:

pairing status of the device.

Return type:

TMSiPairingStatus

get_sdk() CDLL#

Gets the handle of the communication library

Returns:

the handle of the communication library.

Return type:

CDLL

import_configuration(filename: str)#

Imports the file configuration to the device.

Parameters:

filename (str) – name of the file where to export configuration.

Raises:
  • TMSiError – TMSiErrorCode.general_error if import configuration fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

open(dongle_id=65535)#

Opens the connection with the device.

Parameters:

dongle_id (int, optional) – Id of the dongle to use for the connection. Defaults to ApexConst.TMSI_DONGLE_ID_NONE

Raises:
  • TMSiError – TMSiErrorCode.device_error if open connection failed.

  • TMSiError – TMSiErrorCode.no_devices_found if device not found.

pair_device(device_id: int) TMSiDeviceRetVal#

Pairs the device with the dongle

Parameters:

device_id (int) – Id of the device

Returns:

return value of the call

Return type:

TMSiDeviceRetVal

reload_device()#

Reload information from device

Raises:

TMSiError – TMSiErrorCode.api_invalid_command if device is not in connected state

reset_device_card()#

Resets the memory card of the device.

Raises:
  • TMSiError – TMSiErrorCode.device_error if reset card fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

reset_device_data_buffer()#

Resets the incoming buffer.

Raises:
  • TMSiError – TMSiErrorCode.api_invalid_command if device is not in sampling mode

  • TMSiError – TMSiErrorCode.device_error if reset fails

reset_device_event_buffer()#

Resets the incoming event buffer.

Raises:

TMSiError – TMSiErrorCode.device_error if reset fails

reset_to_factory_default()#

Resets the device to default configuration.

Raises:
  • TMSiError – TMSiErrorCode.device_error if reset fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

set_card_recording_config(config: TMSiDevCardRecCfg) TMSiDevCardRecCfg#

Sets the configuration for recording on card.

Parameters:

config (TMSiDevCardRecCfg) – configuration to be set.

Raises:
  • TMSiError – TMSiErrorCode.device_error if set configuration fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

the new available configuration for recording on card.

Return type:

TMSiDevCardRecCfg

set_device_channel_names(names: list, indices: list) list#

Sets the device channel names

Parameters:
  • names (list[str]) – names to be set.

  • indices (list[int]) – index of the channels to edit.

Raises:
  • TMSiError – TMSiErrorCode.device_error if set names fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

  • TypeError – if names is not only strings

  • TypeError – if indices is not only integers.

Returns:

list of new channels.

Return type:

list[ApexChannel]

set_device_download_file_request(file_request: TMSiDevSetCardFileReq)#

Sets the download file request to start or stop the download stream.

Parameters:

file_request (TMSiDevSetCardFileReq) – file request to start or stop.

Raises:
  • TMSiError – TMSiErrorCode.device_error if set device download file request fails.

  • TMSiError – TMSiErrorCode.api_invalid_command if device is not in sampling mode.

set_device_impedance_request(measurement_request: TMSiDevImpedanceRequest)#

Sets the impedance request to start or stop the acquisition.

Parameters:

measurement_request (TMSiSetDeviceImpedanceRequest) – measurement request to start or stop.

Raises:
  • TMSiError – TMSiErrorCode.device_error if set impedance request fails.

  • TMSiError – TMSiErrorCode.api_invalid_command if device is not in the correct state.

set_device_interface(device_interface=DeviceInterfaceType.bluetooth, control=TMSiControl.ControlEnabled) TMSiInterfaceStatus#

Set the device interface.

Parameters:
  • device_interface (DeviceInterfaceType, optional) – the interface to set, defaults to DeviceInterfaceType.bluetooth

  • control (TMSiControl, optional) – enable or disable interface, defaults to TMSiControl.ControlEnabled

Raises:

TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

the new status of the device interface.

Return type:

TMSiInterfaceStatus

set_device_references(list_references: list, list_indices: list)#

Sets the channels to be used as reference.

Parameters:
  • list_references (list[int]) – list of reference values.

  • list_indices (list[int]) – list of indices to be edited.

Raises:
  • TMSiError – TMSiErrorCode.device_error if set references fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

  • TypeError – if references is not only integers

  • TypeError – if indices is not only integers.

Returns:

list of new channels.

Return type:

list[ApexChannel]

set_device_sampling_config(sampling_frequency=ApexBaseSampleRate.Decimal, live_impedance=ApexLiveImpedance.On, impedance_limit=0) TMSiDevSamplingCfg#

Sets the sampling configuration of the device.

Parameters:
  • sampling_frequency (ApexBaseSampleRate, optional) – sample rate to set, defaults to ApexBaseSampleRate.Decimal

  • live_impedance (ApexLiveImpedance, optional) – enable or disable live impedance, defaults to ApexLiveImpedance.On

  • impedance_limit (int, optional) – kOhms value of the impedance limit, defaults to 0

Raises:
  • TMSiError – TMSiErrorCode.device_error if set sampling configuration fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

Returns:

the new sampling configuration

Return type:

TMSiDevSamplingCfg

set_device_sampling_request(measurement_request: TMSiDevSampleRequest)#

Sets the sampling request to start or stop the acquisition.

Parameters:

measurement_request (TMSiDevSampleRequest) – measurement request to configure the acquisition.

Raises:
  • TMSiError – TMSiErrorCode.device_error if set sampling request fails.

  • TMSiError – TMSiErrorCode.api_invalid_command if device is not in sampling mode.

set_device_time(datetime: datetime)#

Sets the datetime of the device.

Parameters:

datetime (datetime.datetime) – datetime to set on the device.

Raises:
  • TMSiError – TMSiErrorCode.device_error if set time fails.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

start_download_file(file_id: int, filename: str = None, n_of_samples: int = None)#

Starts the download of the file requested.

Parameters:
  • file_id (int) – id of the file to download.

  • filename (str, optional) – filename where to write the impedance report (if available), defaults to None

Raises:
  • TMSiError – TMSiErrorCode.file_writer_error if impedance report download fails.

  • TMSiError – TMSiErrorCode.api_invalid_command if already sampling.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

start_measurement(measurement_type: MeasurementType, thread_refresh=None)#

Starts the measurement requested.

Parameters:
  • measurement_type (MeasurementType) – measurement to start

  • thread_refresh (float, optional.) – refresh time for sampling and conversion threads, defaults to None.

Raises:
  • TMSiError – TMSiErrorCode.api_invalid_command if already sampling.

  • TMSiError – TMSiErrorCode.device_not_connected if not connected.

stop_download_file()#

Stops the download of the file.

Raises:

TMSiError – TMSiErrorCode.api_invalid_command if not sampling.

stop_measurement()#

Stops the measurement requested.

Raises:

TMSiError – TMSiErrorCode.api_invalid_command if not sampling.

user_abort_download()#

Interrupts the download after user abort command.