Custom channel wire
Custom Channel Wires extend the built-in Channel wire functionality, allowing developers to create specialized channels tailored to specific application needs. These user-defined channels provide a flexible method for implementing custom communication patterns and data handling strategies in LabVIEW applications, especially when the standard channel wires (such as stream, tag, and message channels) do not fully meet the requirements of a given project.
Overview
Custom Channel Wires are defined by the developer to facilitate unique data transfer and synchronization mechanisms between parallel processes in a LabVIEW application. They can be designed to handle specific data types, include custom data processing or validation logic, and implement specialized synchronization or buffering strategies.
Uses and Applications
Custom Channel Wires can be used in a variety of scenarios, including but not limited to:
- Complex Data Handling: Managing the transfer of complex data structures that require custom serialization or deserialization logic.
- Advanced Synchronization: Implementing advanced synchronization patterns not supported by standard channel wires.
- Real-time Data Processing: Incorporating data processing or filtering directly within the communication channel.
- Specialized Communication Protocols: Emulating specialized communication protocols or adapting to proprietary hardware interfaces.
Creating Custom Channel Wires
Creating a Custom Channel Wire in LabVIEW involves several key steps:
- Navigate to [LabVIEW 20xx]\resource\Channels
- This directory path is the same for Mac and Linux users as well. Inside, you'll find several subdirectories.
- The subdirectories contain one template each. Choose the template subdirectory that is closest to the functionality you wish to implement with your custom channel wire.
- Remember: Pipes will not be forkable, and non-Pipes will be forkable. This is an important consideration when selecting your starting point.
- Within your chosen template subdirectory, you will find a .lvlib file. This file is a LabVIEW library containing all the VIs you need to get started. Open this file in LabVIEW to begin the process.
- After opening the .lvlib file, use File >> Save As >> Copy to save a duplicate of the library and all of its member VIs. Save the duplicate to a new directory located next to the existing templates. This will be your working directory where you can modify and customize the library without affecting the original template.
- (optional) Even without making any further changes, your new channel is now available in the right-click menus. Right-click on a terminal to verify that you see your new library listed in the Create menu.
- Using Save As >> Copy will create a new copy on disk but does not open it in memory. So now open your new .lvlib file.
- Edit the member VIs.
By following these steps, you will have successfully set up a starting point for developing your custom channel wire in LabVIEW 2015. From here, you can proceed to modify the library and its member VIs to implement the specific functionality you need.
The Parts Of A Channel Definition Library
A Channel Definition Library consists of several key components:
Required Components:
- The two files starting with a close parenthesis (")") character.
- )*.ctl - This is the typedef that defines the channel wire itself on user diagrams. Its icon may be modified, but the file should otherwise remain unchanged. A single parenthesis indicates a non-forkable wire, while a double parenthesis indicates a forkable wire.
- )*.vi, aka "the core VI" - This VI, which must be preallocated and reentrant, contains the channel's implementation. It stores any shared state between the writers and readers. It must have the same file name as the .ctl file, except for the extension. The connector pane of this VI should have "channel in" and "channel out" terminals at a minimum.
- Instantiate.vi - This VI generates the VI refnum shared between the write and read endpoints. Typically, it returns a static VI reference. The connector pane of this VI is unusual, having both an input and an output terminal, but only the output should be used.
All remaining member VIs are optional:
- Element.ctl - A variant typedef, not to be altered. It changes to match the data type being carried when the template is instantiated.
- Write______.vi - VIs starting with "Write" appear in the shortcut menu for write endpoints. They typically call the core VI and may be marked as "inline" for efficiency.
- Read______.vi - Similarly, VIs beginning with "Read" appear in the shortcut menu for read endpoints, generally calling the core VI and potentially marked as "inline".
- Probe.vi - A reentrant VI named "Probe.vi" serves as a custom probe for the asynchronous wire. It should be included in the core VI's update call, as seen in the Pipe template.
- Init.vi - This VI, which should be removed from your template, is leftover from development and was intended to be deleted before shipping LV 2015.
- Other VIs in a template:
- Support VIs, like "Grow.vi" in the Pipe template, support the main functions.
- User-called VIs, such as "Replicate2.vi" from the Pipe template, perform specific actions like duplicating pipe contents into two separate outgoing pipes.
You have the freedom to add or remove VIs from the channel library as necessary to meet your application's needs.