API Reference

class flexlogger.automation.AlarmPayload(event_response)[source]

Represents an alarm event payload.

property acknowledged: bool

Whether the alarm has been acknowledged.

property acknowledged_at: datetime

When the alarm was acknowledged.

property active: bool

Whether the alarm is active.

property alarm_id: str

The alarm ID.

property channel: str

Channel associated with the alarm.

property condition: str

The alarm condition.

property description: str

Description of the alarm.

property display_name: str

The alarm’s display name.

property event_name: str

The name of the event received.

property event_type: EventType

The type of event received.

property occurred_at: datetime

When the alarm occurred.

property severity_level: SeverityLevel

The alarm’s severity level.

property timestamp: datetime

The time the event was received.

property updated_at: datetime

When the alarm was last updated.

class flexlogger.automation.Application(server_port=None)[source]

Represents the FlexLogger application.

__init__(server_port=None)[source]

Connect to an already running instance of FlexLogger.

Parameters:

server_port (Optional[int]) – The port that the automation server is listening to. Omit this argument or pass None to detect the port of a running FlexLogger automatically.

Raises:

FlexLoggerError – if connecting fails.

close()[source]

Close the application and disconnect from the automation server.

Further calls to this object will fail.

Return type:

None

disconnect()[source]

Disconnect from the automation server, but leave the application running.

Further calls to this object will fail.

Return type:

None

property event_handler: FlexLoggerEventHandler

The application event handler.

get_active_project()[source]

Gets the currently active (open) project.

Return type:

Optional[Project]

Returns:

The active project, or None if a project is not currently open.

Raises:

FlexLoggerError – if getting the active project fails.

get_version()[source]

Gets the FlexLogger server version.

Return type:

(str, str)

Returns:

A tuple containing the FlexLogger versions (internal version and user visible version).

Raises:

FlexLoggerError – if getting the version fails.

classmethod launch(*, timeout=40, path=None)[source]

Launch a new instance of FlexLogger.

Note that if this method is used to initialize a “with” statement, when the Application goes out of scope FlexLogger will be closed. To prevent this, call disconnect().

Parameters:
  • timeout (float) – The length of time, in seconds, to wait for FlexLogger to launch before raising an exception. Defaults to 40.

  • path (Union[str, pathlib.Path, None]) – The path to the FlexLogger executable to launch. Defaults to None, meaning the latest installed version will be launched.

Return type:

Application

Returns:

The created Application object

Raises:

FlexLoggerError – if launching FlexLogger or connecting to it fails.

open_project(path, timeout=-1)[source]

Open a project.

Parameters:
  • path (Union[str, pathlib.Path]) – The path to the project you want to open.

  • timeout (int) – The timeout in seconds. If the value is negative, it will be ignored and the call will wait indefinitely.

Return type:

Project

Returns:

The opened project.

Raises:

FlexLoggerError – if opening the project fails or the timeout is reached.

property server_port: int

The port that the automation server is listening to.

class flexlogger.automation.ChannelDataPoint(name, value, timestamp)[source]

The value for a channel at the specified timestamp.

property name: str

The name of the channel.

property timestamp: datetime

The timestamp when the value occurred.

property value: float

The value of the channel.

class flexlogger.automation.ChannelSpecificationDocument(channel, raise_if_application_closed, identifier)[source]

Represents the document that describes data channels.

Do not create this class directly; instead, use the return value of Project.open_channel_specification_document().

get_actual_data_rate(channel_name)[source]

Get the actual data rate for the specified channel.

Parameters:

channel_name (str) – The name of the channel.

Return type:

float

get_channel_names()[source]

Get all the channel names in the document.

Raises:

FlexLoggerError – if getting the channel names fails.

Return type:

List[str]

get_channel_value(channel_name)[source]

Get the current value of the specified channel.

Parameters:

channel_name (str) – The name of the channel.

Raises:

FlexLoggerError – if getting the channel value fails.

Return type:

ChannelDataPoint

get_data_rate(data_rate_level)[source]

Get the data rate for a specific date rate level in Hertz.

Parameters:

data_rate_level (DataRateLevel) – The data rate level to get the data rate for.

Raises:

FlexLoggerError – if the data_rate_level is invalid.

Return type:

float

get_data_rate_level(channel_name)[source]

Get the data rate level of the specified channel

Parameters:

channel_name (str) – The name of the channel.

Raises:

FlexLoggerError – if getting the data rate level fails.

Return type:

DataRateLevel

is_channel_enabled(channel_name)[source]

Get the current enabled state of the specified channel.

Parameters:

channel_name (str) – The name of the channel.

Raises:

FlexLoggerError – if getting the channel value fails.

Return type:

bool

set_channel_enabled(channel_name, channel_enabled)[source]

Enable or disable the specified channel.

Parameters:
  • channel_name (str) – The name of the channel.

  • channel_enabled (bool) – The channel enabled state: true to enable the channel, false to disable it.

Raises:

FlexLoggerError – if enabling or disabling the channel fails.

Return type:

None

set_channel_value(channel_name, channel_value)[source]

Set the current value of the specified channel.

Parameters:
  • channel_name (str) – The name of the channel.

  • channel_value (float) – The value to set the channel to.

Raises:

FlexLoggerError – if setting the channel value fails.

Return type:

None

set_data_rate(data_rate_level, data_rate)[source]

Set the data rate of a specific data rate level.

Parameters:
  • data_rate_level (DataRateLevel) – The data rate level to get the data rate for.

  • data_rate (float) – The value of the data rate to set in Hertz.

Raises:

FlexLoggerError – if setting the data rate fails.

Return type:

None

set_data_rate_level(channel_name, data_rate_level)[source]
Set the data rate level of the specified channel

Note: This may affect other channels in the same module or chassis set to the same data rate level.

Parameters:
  • channel_name (str) – The name of the channel.

  • data_rate_level (DataRateLevel) – The data rate level to set.

Raises:

FlexLoggerError – if setting the data rate level fails.

Return type:

None

class flexlogger.automation.DataRateLevel(value)[source]

An enumeration describing the possible data rate levels that channels can be configured to use. For additional information on configuring data rates, visit https://www.ni.com/docs/en-US/bundle/flexlogger/page/configuring-data-rates.html

COUNTER = 4

The counter data rate level in Hertz at which your DAQ device acquires data.

DIGITAL = 6

The digital data rate level in Hertz at which your DAQ device acquires data.

FAST = 3

The fast analog data rate level in Hertz at which your DAQ device acquires data.

MEDIUM = 2

The medium analog data rate level in Hertz at which your DAQ device acquires data.

ON_DEMAND = 7

The on-demand data rate level in Hertz at which your DAQ device acquires data.

SLOW = 1

The slow analog data rate level in Hertz at which your DAQ device acquires data.

class flexlogger.automation.EventPayload(event_response)[source]

Represents an event payload.

property event_name: str

The name of the event received.

property event_type: EventType

The type of event received.

property timestamp: datetime

The time the event was received.

class flexlogger.automation.EventType(value)[source]

An enumeration describing the different types of events.

class flexlogger.automation.FilePayload(event_response)[source]

Represents a file event payload.

property event_name: str

The name of the event received.

property event_type: EventType

The type of event received.

property file_path: str

The TDMS file path.

property timestamp: datetime

The time the event was received.

exception flexlogger.automation.FlexLoggerError(message)[source]

Represents errors that occur when calling FlexLogger APIs.

__init__(message)[source]

Initialize an exception.

Parameters:

message (str) – The message describing the error.

property message: str

The error message.

with_traceback()

Exception.with_traceback(tb) – set self.to tb and return self.

class flexlogger.automation.FlexLoggerEventHandler(channel, client_id, application, raise_if_application_closed)[source]

Represents a FlexLogger event handler. You must create a FlexLoggerEventHandler object to be able to register for events.

get_registered_events()[source]

Gets the list of registered event types.

Return type:

List[EventType]

Returns

The list of registered event types

Raises:

FlexLoggerError – if the request failed.

register_event_callback(callback, event_types=None)[source]

Register for events and specify a callback method

Parameters:
  • callback – callback method. The callback method must have the following parameters: application: Application Reference to the FlexLogger application event_type: EventType The event type event_payload: EventPayload The event payload

  • event_types – List of EventType to subscribe to.

Raises:

FlexLoggerError – if the callback registration failed.

Return type:

None

unregister_from_events()[source]

Unregister from events.

Return type:

None

class flexlogger.automation.LoggingSpecificationDocument(channel, raise_if_application_closed, identifier)[source]

Represents a document that describes how data is logged.

Do not create this class directly; instead, use the return value of Project.open_logging_specification_document().

get_log_file_base_path()[source]

Get the log file base path.

Return type:

str

Returns:

The base path for the log file.

Raises:

FlexLoggerError – if getting the log file base path fails.

get_log_file_description()[source]

Get the log file description.

Return type:

str

Returns:

The description of the log file.

Raises:

FlexLoggerError – if getting the log file description fails.

get_log_file_name()[source]

Get the log file name.

Return type:

str

Returns:

The file name that will be logged to.

Raises:

FlexLoggerError – if getting the log file name fails.

get_resolved_log_file_base_path()[source]

Get the resolved log file base path.

Return type:

str

Returns:

The resolved base path for the log file. The resolved base path will have any placeholders replaced with actual values. Note that time sourced placeholders such as {Second} are resolved at the time of the call, and may resolve to a different time on a subsequent call or when a log file is created.

Raises:

FlexLoggerError – if getting the resolved log file base path fails.

get_resolved_log_file_name()[source]

Get the resolved log file name.

Return type:

str

Returns:

The resolved file name that will be logged to. The resolved file name will have any placeholders replaced with actual values. Note that time sourced placeholders such as {Second} are resolved at the time of the call, and may resolve to a different time on a subsequent call or when a log file is created.

Raises:

FlexLoggerError – if getting the resolved log file name fails.

get_start_trigger_settings()[source]

Get the start trigger settings.

Returns:

  • The start trigger condition

  • The start trigger settings The object returned varies based on the start trigger condition.

    • When the start trigger condition is TEST_START, the object is None

    • When the start trigger condition is CHANNEL_VALUE_CHANGE, the object is of type ValueChangeCondition

    • When the start trigger condition is ABSOLUTE_TIME, the object is a datetime object containing the test start time.

Return type:

A tuple containing 2 strings

Raises:

FlexLoggerError – if getting the start trigger settings fails.

get_stop_trigger_settings()[source]

Get the stop trigger settings.

Returns:

  • The stop trigger condition

  • The stop trigger settings The object returned varies based on the stop trigger condition.

    • When the stop trigger condition is TEST_STOP, the object is None

    • When the stop trigger condition is CHANNEL_VALUE_CHANGE, the object is of type ValueChangeCondition

    • When the stop trigger condition is TEST_TIME_ELAPSED, the object is a string containing the test duration

Return type:

A tuple containing 2 strings

Raises:

FlexLoggerError – if getting the stop trigger settings fails.

get_test_properties()[source]

Get all test properties.

Return type:

List[TestProperty]

Returns:

A list of the test properties on this document.

Raises:

FlexLoggerError – if getting the test properties fails.

get_test_property(test_property_name)[source]

Get the test property with the specified name.

Throws a FlexLoggerError if a property with the specified name does not exist.

Parameters:

test_property_name (str) – The name of the test property.

Return type:

TestProperty

Returns:

The TestProperty with the specified name.

Raises:

FlexLoggerError – if a property with the specified name does not exist, or if getting the property fails.

is_retriggering_enabled()[source]

Get the re-triggering configuration.

Return type:

bool

Returns:

True if re-triggering is enabled, False otherwise

Raises:

FlexLoggerError – if getting the re-triggering configuration fails.

remove_test_property(test_property_name)[source]

Removes the test property with the specified name.

Parameters:

test_property_name (str) – The name of the test property.

Raises:

FlexLoggerError – if a property with the specified name does not exist, or if removing the property fails.

Return type:

None

set_log_file_base_path(log_file_base_path)[source]

Set the log file base path.

Parameters:

log_file_base_path (str) – The log file base path.

Raises:

FlexLoggerError – if setting the log file base path fails.

Return type:

None

set_log_file_description(log_file_description)[source]

Set the log file description.

Parameters:

log_file_description (str) – The log file description.

Raises:

FlexLoggerError – if setting the log file description fails.

Return type:

None

set_log_file_name(log_file_name)[source]

Set the log file name.

Parameters:

log_file_name (str) – The log file name.

Raises:

FlexLoggerError – if setting the log file name fails.

Return type:

None

set_retriggering(retriggering)[source]

Set the re-triggering configuration.

Parameters:

retriggering (bool) – True to enable re-triggering, False to disable it.

Raises:

FlexLoggerError – if setting the re-triggering configuration fails.

Return type:

None

set_start_trigger_settings_to_absolute_time(time)[source]

Set the start trigger to Absolute Time

Parameters:

time (<module ‘datetime’ from ‘/home/docs/.asdf/installs/python/3.10.13/lib/python3.10/datetime.py’>) – Test start time. If it’s timezone-naive, it’s assumed to be in UTC.

Raises:

FlexLoggerError – if setting the start trigger fails.

Return type:

None

set_start_trigger_settings_to_test_start()[source]

Set the start trigger to Test Start

Raises:

FlexLoggerError – if setting the start trigger fails.

Return type:

None

set_start_trigger_settings_to_value_change(value_change_condition)[source]

Set the start trigger to Channel Value Change

Parameters:

value_change_condition (ValueChangeCondition) – The value change parameters as an object of type ValueChangeCondition

Raises:

FlexLoggerError – if setting the start trigger fails.

Return type:

None

set_stop_trigger_settings_to_duration(duration)[source]

Set the stop trigger to Test Time Elapsed

Parameters:

duration (datetime.timedelta) – The length of time after which to stop the test.

Raises:

FlexLoggerError – if setting the stop trigger fails.

Return type:

None

set_stop_trigger_settings_to_test_stop()[source]

Set the stop trigger to Test Stop

Raises:

FlexLoggerError – if setting the stop trigger fails.

Return type:

None

set_stop_trigger_settings_to_value_change(value_change_condition)[source]

Set the stop trigger to Channel Value Change

Parameters:

value_change_condition (ValueChangeCondition) – The value change parameters as an object of type ValueChangeCondition

Raises:

FlexLoggerError – if setting the stop trigger fails.

Return type:

None

set_test_properties(test_properties)[source]

Set test properties.

Parameters:

test_properties (List[TestProperty]) – A list of test properties to add or modify on this document.

Raises:

FlexLoggerError – if setting the test properties fails.

Return type:

None

set_test_property(property_name, property_value, prompt_on_start=False)[source]

Set the information for a test property.

Use this method to add a new test property or to modify an existing test property.

Parameters:
  • property_name (str) – The name of the test property. If a test property already exists with the same name, that test property will be updated with the new information passed to this method. Otherwise, a new test property will be created to reflect the specified test information.

  • property_value (str) – The property value to set.

  • prompt_on_start (bool) – Whether this property should be set when the test session starts. Defaults to False. If this is set to True, the operator should be prompted to define this property when the test session starts.

Raises:

FlexLoggerError – if setting the property fails.

Return type:

None

class flexlogger.automation.Project(channel, raise_if_application_closed, identifier)[source]

Represents a FlexLogger project.

Do not create this class directly; instead, use the return value of Application.open_project().

close()[source]

Close the project.

Raises:

FlexLoggerError – if closing the project fails.

Return type:

None

open_channel_specification_document()[source]

Open the channel specification document in the project.

Return type:

ChannelSpecificationDocument

Returns:

The opened document.

Raises:

FlexLoggerError – if opening the document fails.

open_logging_specification_document()[source]

Open the logging specification document in the project.

Return type:

LoggingSpecificationDocument

Returns:

The opened document.

Raises:

FlexLoggerError – if opening the document fails.

open_screen_document(filename)[source]

Open the specified screen document in the project.

Parameters:

filename (str) – The name of the screen document to open. Including the .flxscr extension in this argument is optional.

Return type:

ScreenDocument

Returns:

The opened document.

Raises:

FlexLoggerError – if a screen document of the specified name does not exist, or if opening the document fails.

open_test_specification_document()[source]

Open the test specification document in the project.

Return type:

TestSpecificationDocument

Returns:

The opened document.

Raises:

FlexLoggerError – if opening the document fails.

property project_file_path: Path | None

Get the project file path on disk

Returns: The saved project file path if it exists, None otherwise

property project_name: str | None

Get the project name

Returns: The project name if the file path exists, None otherwise

save()[source]

Save the project.

Raises:
  • FlexLoggerError – if saving the project fails due to a communication error.

  • If there is no communication error with the FlexLogger application, this function will not raise an

  • exception, but instead return a boolean indicating if the project was properly saved.

Return type:

None

property test_session: TestSession

Get the test session for the project.

class flexlogger.automation.ScreenDocument(channel, raise_if_application_closed, identifier)[source]

Represents a document that displays data.

Do not create this class directly; instead, use the return value of Project.open_screen_document().

Note that this class currently has no functionality; more functionality may be added in the future.

class flexlogger.automation.SeverityLevel(value)[source]

Represents the severity level of an alarm.

class flexlogger.automation.StartTriggerCondition(value)[source]

An enumeration describing when to the logging starts.

CHANNEL_VALUE_CHANGE = 1

Begin logging at a designated date and time.

TEST_START = 0

Begin logging when the value of the channel meets the specified value change condition.

class flexlogger.automation.StopTriggerCondition(value)[source]

An enumeration describing when to the logging stops.

CHANNEL_VALUE_CHANGE = 1

Stop logging after a designated duration of time has elapsed.

TEST_STOP = 0

Stop logging when the value of the acquisition on a designated channel meets the specified value change condition.

class flexlogger.automation.TestProperty(name, value, prompt_on_start)[source]

Information about a test property.

__init__(name, value, prompt_on_start)[source]

Create a new TestProperty.

Parameters:
  • name (str) – The name of the property.

  • value (str) – The value of the property.

  • prompt_on_start (bool) – Whether the operator should be prompted to define this property when the test session starts.

property name: str

The name of the property.

property prompt_on_start: bool

Whether this property should be set when the test session starts.

If this is set to true, the operator should be prompted to define this property when the test session starts.

property value: str

The value of the property.

class flexlogger.automation.TestSession(channel, raise_if_application_closed)[source]

Represents a test session for a project.

Do not create this class directly; instead, use the property Project.test_session.

add_note(note)[source]

Add a note to the current log file.

This method requires the test session to be in the TestSessionState.RUNNING state.

Parameters:

note (str) – The note to add to the log file.

Raises:

FlexLoggerError – if the test session is not in the TestSessionState.RUNNING state, or if adding the note fails.

Return type:

None

property elapsed_test_time: timedelta

Queries the elapsed test time

Returns:

The current tests’s elapsed time if a test is running or paused, the most recent test’s elapsed time if a test has been run and stopped.

Raises:

FlexLoggerError – if no test has ever been run since the project was loaded

pause()[source]

Pauses the test session, if possible.

Return type:

bool

Returns:

True if the test was paused, otherwise False.

Raises:

FlexLoggerError – if pausing the test session fails.

resume()[source]

Resumes the test session, if possible.

Return type:

bool

Returns:

True if the test was resumed, otherwise False.

Raises:

FlexLoggerError – if resuming the test session fails.

start()[source]

Start the test session, if possible.

Return type:

bool

Returns:

True if the test was started, otherwise False.

Raises:

FlexLoggerError – if starting the test session fails.

property state: TestSessionState

Get the current state of the test session.

Raises:

FlexLoggerError – if getting the current state fails.

stop()[source]

Stop the test session, if possible.

Return type:

bool

Returns:

True if the test was stopped, otherwise False.

Raises:

FlexLoggerError – if stopping the test session fails.

class flexlogger.automation.TestSessionState(value)[source]

An enumeration describing the possible states of a TestSession.

IDLE = 1

The TestSession is idle and not running.

Configuration changes can occur during this state.

INVALID_CONFIGURATION = 3

The project has a configuration error.

NO_VALID_LOGGED_CHANNELS = 4

No channels have been configured, or all channels are disabled or not available.

PAUSED = 5

The TestSession is paused.

Logging and events are not active while the test session is paused.

Configuration changes are not allowed when the test session is paused.

RUNNING = 2

The TestSession is running.

Logging and events are active while the test session is running.

Configuration changes are not allowed when the test session is running.

class flexlogger.automation.TestSpecificationDocument(channel, raise_if_application_closed, identifier)[source]

Represents a document that describes a test.

Do not create this class directly; instead, use the return value of Project.open_test_specification_document().

Note that this class currently has no functionality; more functionality may be added in the future.

class flexlogger.automation.ValueChangeCondition(value_change_condition='')[source]

Represents a value change condition. Create a ValueChangeCondition object when you want to set the start or stop trigger to value change.

property channel_name: str

The channel name.

property max_value: float

The range maximum.

property min_value: float

The range minimum.

property threshold: float

The threshold.

property time: float

The leading or trailing time in seconds.

property value_change_type: ValueChangeType

The value change type.

class flexlogger.automation.ValueChangeType(value)[source]

An enumeration describing the possible types of value change events.

ENTER_RANGE = 5

Start or stop a test when a channel value leaves a range.

FALL_BELOW_VALUE = 3

Start or stop a test when a channel value enters a range.

NONE = 0

Start or stop a test when a channel value rises above a specified value.

RISE_ABOVE_VALUE = 1

Start or stop a test when a channel value falls below a specified value.

Indices and tables