250 likes | 418 Views
Welcome!. Workshop 5 of 7. Today's Topics. Review of Workshop 4 File Input/ Ouput Binary files TDMS files Polymorphic VIs. Review Question 1. Which of the following are reasons for using a multiple loop design pattern ? Execute multiple tasks concurrently
E N D
Welcome! Workshop 5 of 7
Today's Topics • Review of Workshop 4 • File Input/Ouput • Binary files • TDMS files • Polymorphic VIs
Review Question 1 • Which of the following are reasons for using a multiple loop design pattern? • Execute multiple tasks concurrently • Execute different states in a state machine • Execute tasks at different rates • Execute start up code, main loop, and shutdown code
Review Question 1 • Which of the following are reasons for using a multiple loop design pattern? • Execute multiple tasks concurrently • Execute different states in a state machine • Execute tasks at different rates • Execute start up code, main loop, and shutdown code
Review Question 2 • The major difference between Notifiers and Queues is: • Notifiers cannot send data with the notification, but queues can. • Notifierscannot buffer data that is sent, but queues buffer data. • Notifierswill make the slave loop wait on the notification, a queue does not make the slave loop wait.
Review Question 2 • The major difference between Notifiers and Queues is: • Notifiers cannot send data with the notification, but queues can. • Notifierscannot buffer data that is sent, but queues buffer data. • Notifierswill make the slave loop wait on the notification, a queue does not make the slave loop wait.
Review Question 3 • Which of the following are valid data types for queues and notifiers? • String • Numeric • Enum • Array of Booleans • Cluster of a String and a Numeric
Review Question 3 • Which of the following are valid data types for queues and notifiers? • String • Numeric • Enum • Array of Booleans • Cluster of a String and a Numeric
File Input/Output • At their lowest level, all files written to your computer’s hard drive are a series of bits
File Input/Output Architecture • File I/O writes to or reads from a file • A typical file I/O operation involves the following process: Open/Create/Replace File Read and/orWrite to File Close File Check for Errors
File I/O: Writing (Binary) • Strings • series of unsigned 8-bit integers, each of which has a value in the ASCII Character Code Equivalents Table • Arrays • represented as a sequential list of the elements (representation dependent on data type of element) • a header contains a 32-bit integer representing the size of each dimension • Boolean • LabVIEW represents Boolean values as 8-bit values in a binary file • Eight zeroes represents False • [00000000] • Any other value represents True • [00000001], [01000110], [11111111], etc • Integers • Binary ValueU8 Value • 00000000 0 • 00000001 1 • 00000010 2 • 11111111 255
File I/O: Reading (Binary) • Two methods of accessing data: • Sequential Access—Read each item in order, starting at the beginning of a file • Random Access—Access data at an arbitrary point within the file Random Sequential
File I/O: TDMS (Technical Data Management Streaming) • TDMS file • Binary file (.tdms) that contains data and stores properties about the data • TDMS_Index file • Binary index file (*.tdms_index) that provides consolidated information on all the attributes and pointers in the TDMS file • Speeds up access to the data while reading • Automatically regenerated if lost • TDMS file format internal structure is publicly documented
File I/O: TDMS • Channel • Stores measurement signals or raw data in a TDMS file • Each channel can have properties describing the data • The data stored in the signal is stored as binary data on disk to conserve disk space and improve efficiency • Channel Group • Segment of a TDMS file that contains properties and one or more channels • Use channel groups to organize your data and to store information that applies to multiple channels
File I/O: TDMS • Properties • You can assign properties to • entire file • Channel Groups • individual Channels • Examples: • File: Date/Time of logging, user signed into system • Channel Groups: Location of sensor group (top of the bridge), types of sensors (strain, temperature, etc.) • Channel: Sensor ID, max/min readings
File I/O: TDMS Functions • Use the Express VIs : • quick, but little control of organization • --- Write to Measurement File • --- Read from Measurement File • Use the TDM Streaming API • Total control over organization, more involved set-up • Use the TDM Excel Add-In Tool • Allows you to read TDMS files in Microsoft Excel
File I/O: TDMS • Data subset to read/write is determined by group name and channel name(s) inputs
File I/O: TDMS • Setting/getting the properties of the TDMS file, channel group, or channel is dependent on if the group or channel name is specified
File I/O: TDMS File Viewer • Opens TDMS file and presents the file data in the TDMS File Viewer dialog box
Demonstration: TDMS Viewer in Action
Polymorphism • Definition: a programming language feature that allows values of different data types to be handled using a uniform interface. • In LabVIEW: the ability of VIs and functions to automatically adapt to accept input data of different data types • i.e. Numeric Functions • Useful when performing the same operation on different data types
Creating Polymorphic VIs • Create and save VIs that will be instances of the polymorphic VI • - Note: VIs must have the same connector panes • File » New…» Polymorphic VI • Add VIs to list of Instance VIs • 3b. Select other options; edit Icon • File » Save • - Your polymorphic is saved and available for use in block diagrams