What is a session-based API?
Many LabVIEW toolkits can be defined as session-based APIs where there is always a beginning and an end to an interaction with some object. This could be an instrument driver like the DAQmx driver where the API is used to configure and control the DAQ board, an API for reading and writing to configuration (.INI) files, or even an API for communicating over TCP. Session-based API is characterized by the definition "a period of time devoted to a specific activity". We often see these session-based APIs with an initialization/configuration or 'open connection' operation, a series of operations to manipulate & control the session, and an ending or closing of the session. This is a common model used for APIs in LabVIEW, let's take a look at DAQmx and the Configuration File palettes:
Great, how does this relate to me?
As you can see in the images above and by browsing the palettes in LabVIEW, most LabVIEW APIs created by NI R&D have a unique reference data type (Instrument IO References, File I/O References, etc.), access to property & method nodes, and an associated wire color for the different reference types in these APIs. To date, creating a new custom reference type has not been exposed to third-parties, which often results in third-party developers using a cluster to pass their session data between their API VIs. However, LabVIEW classes provide some very useful features like defining custom wire appearances & property nodes. Lets take a look at how LabVIEW classes can be used in our APIs.
In the image below, I have created a session-based API by defining my own ZIP File.lvclass. Using a LabVIEW class lets me as the developer define my own custom wire appearance, which will set my API apart from other LabVIEW .ZIP toolkits and prevents my customers from attempting to accidentally misuse my API by combining it with other file I/O operations. I also created a custom property for this API where, when called, behind the scenes it executes a VI to read the File Size for my .ZIP file. The advantage of using a property node instead of a VI to read this property is you can combine multiple property operations into a single Property Node and avoid stringing together additional VIs on the block diagram. This makes my API much easier for my customers to use.
This image displays a session-based API for working with .ZIP files that uses a LabVIEW class - notice the custom property node for reading the file size & the custom wire type. I've attached the code below.
You mentioned LVOOP, where does it come into play?
In order to create the ZIP file API shown above, I used a tool created by Systems Engineering called the Extensible Session Framework (ESF) to generate the starter code & framework used in my session-based API. This tool makes use of scripting, LVOOP and LabVIEW Classes to generate a template project and LabVIEW class framework with an architecture optimized for use in a session-based API. Here are some of the features:
Please review the attached slide deck for an overview of the Extensible Session Framework and I encourage you to head over to the to view the accompanying example code & download their VI Package containing the tool used to generate ESF template classes as I have done:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.