Documentation Home Page RT-LAB Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

Datalogger API Module

Page Content

class DataloggerApi.Frame

Recorded data and frame metadata.

A frame may be incomplete when retrieved from a running model.

Attributes (private):

  • timestamps (tuple of float): the timestamps (in nanoseconds) of the recorded data.

  • signals_data (tuple of tuple of float): list of values per recorded signal present in the frame.

  • signal_count (int): number of signals returned.

  • step_count (int): number of steps filled (corresponds to the number of values returned for each signal).

  • time_step_ns (int): step duration in nanoseconds.

  • is_complete True when this is the last (or only) part of the frame, False otherwise.

get_signal_count()

Returns signal count.

The number of signals for which values are present in this frame.

get_signals_data()

Returns: (tuple of tuple of float) a tuple of values per signal.

get_step_count()

Returns step count.

This value may be less than configured when a subframe (i.e. a part of a frame) has been retrieved.

get_timestamps()

Returns: (tuple of int) a tuple containing the timestamps (in nanoseconds) of the retrieved data.

is_complete()

Returns status indicating whether this is the last part of the frame.

class DataloggerApi.FrameConfig(signal_names=(), start_time_ns=0, step_count=0, frame_size_ns=0)

Detailed information on the frame configuration.

Related methods: SignalGroup.get_frame_config() SignalGroup.configure_frame()

Args:

  • signal_names (tuple of str): list of signals for which the values must be retrieved.

  • start_time_ns (int): start time of the frame in nanoseconds (file interface only).

  • frame_size_ns (int): frame size in nanoseconds. 0 (default): the frame is auto-sized.

  • step_count (int): number of steps per frame.

get_frame_size()

Returns the frame size (nanoseconds).

get_signals()

Returns signal names (tuple containing names of signals to record).

get_start_time()

Returns start time of the frame (nanoseconds).

get_step_count()

Returns the number of steps in the frame.

set_frame_size(frame_size_ns)

Set frame size (nanoseconds).

Args:

  • frame_size_ns (int): the required frame size in nanoseconds.

Note: This size must not be greater than the one defined with the GUI when interacting with a running model.

set_signals(signal_names)

Set signal names.

Defines the list of signals that must be recorded.

Args:

  • signal_names (tuple of str): tuple containing the names of the signals to record.

Note: The signal source from the SignalInfo class may be used to build the list of signal names. The SignalGroup.get_signals_info() method returns the signal group’s list of signal infos.

set_start_time(start_time_ns)

Set the frame start time (in nanoseconds).

Args:

  • start_time_ns (int): start time of the frame (file interface only).

set_step_count(step_count)

Set the number of steps in the frame.

Args:

  • step_count (int): number of steps in the frame.

set_step_count_from_duration(duration_ns, time_step_ns)

Compute step count from duration and time step.

Utility method to simplify call to set_step_count().

Args:

  • duration_ns (int): duration of the frame in nanoseconds.

  • time_step_ns (int): time step of the frame in nanoseconds.

DataloggerApi.RecordingStatus

alias of DataloggerApi.Enum

class DataloggerApi.SignalGroup(arg1, arg2=-1)

SignalGroup can be connected to a dedicated signal group or to a .oprec file.

Args:

  • arg1 (str): IP address (live streaming) or file name (file streaming).

  • arg2 (str or int): connection port or signal group name (live streaming) or default value (file streaming).

clear_trigger()

Removes a previously defined trigger.

Note: Only available for file streaming.

close()

Close the connection to the DataLoggerTool.

Explicitly closes the instance’s connection to the DataLoggerTool in case garbage collector has failed to do so.

Further calls to any method of the instance will return an error (invalid connection).

Returns: Error code if any, or None.

configure_frame(frame_config)

Configures data frames to be retrieved.

This function MUST be called before any call to get_frame().

Args:

  • frame_config (FrameConfig): frame configuration parameters.

configure_trigger(trigger_config)

Updates trigger configuration.

Args:

  • trigger_config (TriggerConfig): trigger configuration with the following attributes set appropriately: trigger_level, trigger_type, trigger_holdoff.

get_file_name()

Retrieves the recording file name.

Returns: (str) the name of the file in which the signals’ values are stored.

get_frame_config()

Retrieves information about the current frame configuration

Returns: (FrameConfig).

get_last_error_message()

Retrieve error message of the last encountered error.

Returns: (str) the last error message.

get_lost_steps()

Retrieves the lost step list.

Returns: (tuple of int) a tuple of timestamps of the lost steps.

get_recording_status()

Retrieves the current recording status.

Returns: (int) the status of the recording. Refer to RecordingStatus for available statuses.

get_signals_info()

Retrieves information about the available signals.

Returns: (tuple of SignalInfo) tuple of SignalInfo objects.

get_step_info()

Retrieves the step info.

Returns: (StepInfo).

get_sub_frame()

Retrieves data according to the configured frame.

The frame MUST be configured (with configure_frame()) before calling this function. For the live streaming, this function returns the latest subframe recorded by the DataLogger.

The returned sub-frame may or may not be complete for live streaming, and is always complete for file streaming.

Returns: (Frame) filled with the values of the configured signals.

Raises:

  • DataloggerApi.exceptions.NoDataAvailableError: No data are available, try later to get next frame data (live streaming only).

get_timestamp_range()

Retrieves information about the timestamps (min and max).

Returns: (TimeStampRange).

get_trigger_config()

Retrieves information about the current trigger configuration.

Returns (TriggerConfig) containing following trigger information: trigger_level, trigger_type, trigger_holdoff.

save_as(dest_type, dest_file_path=None)

Converts current instance to other file type and save it to the file system.

Args:

  • dest_type (FileType): the type to convert to.

  • dest_file_path (str): full path to the destination file. If not specified, the current file path is used with the file extension replaced.

Returns: (str): generated output file path.

Exceptions: OprecConversionError: conversion error

set_trigger(trigger_config)

Set new trigger.

Args:

  • trigger_config (TriggerConfig): trigger configuration with the following attributes set appropriately: signal_name, trigger_type, trigger_level, offset_sec.

start_recording(file_name=”)

Starts the recording of the .oprec file.

Args:

  • file_name (str): the file name used to store signals’ values. When not specified, the preconfigured file name is used along with integer id. This id is incremented for each started record.

stop_recording()

Stops the recording of the .oprec file.

class DataloggerApi.SignalGroupInfo(id=”, recorder_name=”, name=”, filename=”, port=0)

Information on a signal group.

This class is instantiated by the get_signal_groups_info() function.

Args:

  • id (str): unique recorder identifier.

  • recorderName (str): Recorder name as seen in UI.

  • name (str): signal group name.

  • filename (str): file name defined for the signal group.

  • port (int): TCP/IP port used to communicate with the signal group.

get_filename()

Returns the file name associated with the signal group.

Signals’ data are stored in this file.

get_id()

Returns signal group id.

get_name()

Returns signal group name.

get_port()

Returns the communication port of the signal group.

get_recorder_name()

Returns Recorder Name.

class DataloggerApi.SignalInfo(source=”, type=”, destination=”, id=”, direction=”, label=”, alias=”)

Detailed information on a signal.

This class is instantiated by SignalGroup.get_signals_info().

Args:

  • source (str): Connection point name in the model. This is the name used to configure the frame (see FrameConfig.set_signals()).

  • type (str): Type of connection point (the source).

  • destination (str): Connection point name in the Datalogger.

  • id (str): Unique identifier of the connection between model and Datalogger.

  • direction (str): Direction of recorded data.

  • label (str): Signal’s label.

  • alias (str): Alias set by user on the signal.

get_alias()

Returns signal alias.

get_destination()

Returns signal destination.

get_direction()

Returns signal direction.

get_id()

Returns signal id.

get_label()

Returns signal label.

get_source()

Returns signal source.

The source name may be used to configure a frame (see FrameConfig.set_signals()).

get_type()

Returns signal type.

class DataloggerApi.StepInfo(time_step_ns=0)

Information about the step.

This class is instantiated by SignalGroup.get_step_info()

Args:

  • time_step_ns (int): time step in nanoseconds.

get_time_step()

Returns time step in nanoseconds.

class DataloggerApi.TimeStampRange(min_timestamp_ns=0, max_timestamp_ns=0)

Range of timestamps.

Args:

  • min_timestamp_ns (int): minimum timestamp of the range in nanoseconds.

  • max_timestamp_ns (int): maximum timestamp of the range in nanoseconds.

get_max_time()

Returns max timestamp (in nanoseconds).

get_min_time()

Returns min timestamp (in nanoseconds).

class DataloggerApi.TriggerConfig(signal_name=None, level=0.0, type=None, holdoff_steps=0, offset_sec=0)

Detailed information on the trigger configuration.

Related methods: SignalGroup.set_trigger() SignalGroup.get_trigger_config() SignalGroup.configure_trigger()

Args:

  • signal_name (str): Trigger signal name (file trigger only).

  • type (TriggerConfig.type): Trigger type.

  • level (float): Reference value activating the trigger.

  • holdoff_steps (int): Percentage of the record length allocated to the values before the trigger

  • event occurs (live trigger only).

  • offset_sec (float): Offset in seconds (file trigger only).

get_holdoff()

Returns trigger holdoff.

The number of simulation steps before re-arming the trigger.

get_level()

Returns trigger level.

get_offset()

Returns offset (in seconds).

get_signal()

Returns the name of the signal used for the trigger.

get_type()

Returns trigger type.

set_holdoff(trigger_holdoff)

Set trigger holdoff (in computation steps).

Args:

  • trigger_holdoff (int): number of steps before re-arming the trigger.

set_level(trigger_level)

Set trigger level.

Args:

  • trigger_level (float): reference value used for the trigger.

set_offset(offset_sec)

Set offset (in seconds).

Useful when working on OPREC files.

Args:

  • offset_sec (float): defines starting point from which to take the trigger into account.

set_signal(signal_name)

Set signal name.

Args:

  • signal_name (str): name of the signal used for the trigger.

set_type(trigger_type)

Set trigger type.

Args:

  • trigger_type (TriggerConfig.type): defines the type of trigger (edge rising/falling or level high/low).

type

  • alias of Enum

DataloggerApi.enum(**enums)

DataloggerApi.flush_cache(self)

flush internal cash. It mainly maintains connection information.

DataloggerApi.get_signal_groups_info(ip)

Retrieves information about signal groups.

Args:

  • ip (str): IP address to query for available data loggers.

Returns: (tuple of SignalGroup) tuple of SignalGroup objects.

OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | opal-rt.com | +1 514-935-2323