Example Code

Automating FlexLogger With Python API

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • FlexLogger

    Programming Language

  • Python

Code and Documents

Attachment

Description

This example will guide you through the process of automating your data acquisition using the Flexlogger Python API. With this code, you will be able to:

  • Launch a Flexlogger instance.
  • Open an existing project.
  • Get and set channel properties prior to the test.
  • Get and set logging configurations.
  • Execute a test.
  • Complete a test.

How to Use

FlexLogger and Python Previous Setup 

Before integrating FlexLogger with Python, there are multiple necessary steps that must be completed. For further guidance on these prerequisites, please consult the Flexlogger Getting Started Guide.  Make sure the project you will execute the automation on exists and also the channels are configured. If channels are not configured you will get an error.

 

Executing the Script 

  • Open windows cmd  and avigate to the folder where the script is located, use the cd command.
  • Run the script using the Python command and the existing project path example (py DataLoggingAutomationSript.py "<Project Path>\<Project Name.flxproj>")
  • Follow the instructions when prompted.

Additional Information

The API is tailored to meet your needs if you're seeking to automate your data acquisition process and prefer to utilize Python instead of the Flexlogger user interface. This functionality was added in Flexlogger 2020 R3 and can be used in all subsequent versions.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors