Skip to main content

Data Storage

Choosing Between Text Files and Binary Data Files

In testing programs where data collection is a routine part, deciding how to store this data is crucial. The decision boils down to whether to use text files or binary data files. Text files, readable by humans directly, offer lower efficiency and consume more storage space. Binary files, though not directly interpretable by humans, provide higher efficiency. For data that is frequently accessed but not voluminous, such as configuration settings or test outcomes, text files are the go-to option. For larger data sets, such as collected signals, binary files are more suitable.

Wherever possible, it's recommended to stick to file formats that LabVIEW supports to ensure rational data storage and speed up the development process. LabVIEW’s functionalities for various file operations can be found under "Programming -> File I/O" in the function palette.

Text Files

The two most common file formats LabVIEW supports are INI and XML. INI files, with their simple format, are typically used to store configuration details. An INI file consists of entries, each on a new line, comprising a name and a value. Their simplicity is their biggest advantage, making them ideal for storing a range of configuration details such as user interface positions and default user selections. While applications on Windows might prefer storing this information in the registry, considering cross-platform needs, INI files offer better portability.

INI files fall short when it comes to storing complex information. For example, data with multiple hierarchical levels – a company with various factories, each factory with several departments, each department with numerous production lines, and each line producing multiple products, each with its serial number, production date, and other details. For such complex hierarchical data, the XML file format is more suitable, albeit more complex to use.

Binary Data Files

Binary data files can't be directly opened and read, so there's no need to concern yourself with their specific disk format. LabVIEW offers an efficient file format, TDMS, specifically for signal data storage. Thanks to its rational data storage design, TDMS allows for simultaneous data collection and hard disk storage. When necessary, the required data can be quickly retrieved. Users don't need to understand the intricacies of the TDMS format, just the usage of its associated functions. The TDMS-related functions are intuitive and located in the Programming -> File I/O->TDM Stream function panel. Common functions like writing and reading can be inferred from their names.

Occasionally, you might find valuable data, such as a recently displayed waveform, on the VI front panel that needs to be saved. Such spontaneous data storage needs can't be addressed programmatically. In such cases, you can select Operation -> Data Record -> Record from the VI front panel menu to save all current interface data in a binary data file. To view the data later, open the same VI front panel, select Operation -> Data Record -> Get from the menu, and the data from the file will be read back into the VI control.

Database

LabVIEW features a dedicated database connection tool that assists users in reading and writing database data within LabVIEW. With LabVIEW's database connection tool, users can conveniently store or retrieve data from the database without needing a deep understanding of various database concepts.

Databases are used to manage interrelated data that can be represented in a tabular form. One major advantage of a database is the convenience it offers in data retrieval. However, the original data generated by each test program usually lacks significant correlation, and there's rarely a need to search for specific data within a curve, so simple test data generally doesn't need to be saved to a database. Another advantage of a database is its ability to manage data uniformly. For instance, a company can have a public database where all test data is stored.

Generate Reports

After the completion of a test program, it's often necessary to present the test results to the user in the form of a written report. LabVIEW can generate four types of report formats: standard, HTML, Word, and Excel. Word and Excel formats are only available after installing the LabVIEW report generation tool. To print a professional and aesthetically pleasing report, you can first generate a Word or Excel format file; then open the generated report in MS Office software, check it, and make minor modifications to any areas where the format is not ideal; then print the report directly from Office.

The task of generating reports isn't difficult, but it can be quite tedious. When generating Word or Excel format reports, if the report's content and format are fully implemented programmatically, the workload can be quite substantial. Therefore, it's advisable to first create a template for the report: use MS Office software to design the report format, and write all the text that can be pre-written, leaving only the data, conclusions, etc., that need to be added after the test ends. This way, the program only needs to insert a small amount of content into the report template, which can significantly speed up program development.