LabVIEW Development Best Practices Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Measurement Abstraction Plugin Framework with Optional TestStand Interface

Author: Elijah Kerry, CLA

Last update: May 19th, 2018 (NIWeek 2018)

 

Picture1.pngOverview of the Measurement Abstraction Framework

The attached code serves as a reference architecture for the core architecture of large-scale test and measurement systems, especially long-running tests that are commonly associated with the characterization and validation of a physical system. 

 

The Measurement Abstraction Framework demonstrates solutions that address the following common requirements:

  1. Hardware Abstraction Layer(s): The de-coupling of hardware and instrumentation through a class interface that allows tests to be easily reconfigured to utilize different devices or vendors without modifying test code
  2. Measurement Abstraction Layer(s): The ability to change and override the default behavior and display of a measurement based on a class interface without modifying test code
  3. Channel and DUT Abstraction: The ability to map IO for a specific device to sensors or a DUT in a way that can be stored and referenced without specific knowledge of the device in use
  4. Factory patterns for plugins: Dynamic loading of new capabilities and functionality without modifying or even restarting the main framework
  5. Simplified test definition: How to enable the creation of tests by users who are not experts on the framework or advanced programming concepts like OOP
  6. Logging heterogenous data: How to stream data from multiple devices at multiple rates in a way that can easily be correlated and analyzed offline
  7. Storing/aggregating data in a central location: How to upload the data from tests to NI SystemLink for visualization and offline analysis
  8. Asynchronous actors: Usage of Actor Framework for a highly asynchronous system that allows multiple sub-systems to communicate while acting independently 
  9. Configuration storage: how to store device and measurement configuration to disk for later reference, as well as how to pass this information to TestStand
  10. Simplification of TestStand: simplify test definition in TestStand through configuration-based workflows that employ custom step types
  11. Reusable across validation or production: the framework is designed to execute the same measurements and devices purely from LabVIEW or they can be sequenced and the channel names can be referenced from TestStand tests
  12. Remote execution of tests on RT targets: How to sequence the execution of tests running on a Linux Real-Time target from a Window Host running TestStand. Note: this functionality was available in previous versions but is not in the 5.3 release yet. It will be re-added after NIWeek 

Example Overview

Version 5.0 has been used to build an EV Powertrain Validation test demonstration, which will appear on the Expo floor of NIWeek, as well as various locations around then world. The attached code includes the device plugins that were used for this particular application. Once installed, it can be run, but will almost certainly generate an error unless you happen to have the same hardware at your disposal. The primary reason these were included is to serve as helpful examples for how driver plugins should be written.

 

To run the example without hardware, we recommend simulating one or more DAQ devices for use with the Standard Measurement.

 

Setup and Installation

  1. Written and designed for LabVIEW 2017 SP1. Will be tested against LabVIEW 2018 after NIWeek
  2. The attached VIPC contains all of the necessary libraries required to run the framework, as well as one sample measurement plugin and device plugin examples for: DAQ, CAN, RMX Power Supply, Anderson Load, and a Thermotron thermal chamber. 
  3. One installed, navigate in VIPM to the TestStand Interface for MAF package and click "Show Examples"
  4. Open the project in that directory and launch and run "TestStand Interface Test Harness.vi." Clicking the buttons in order will allow you to configure the controller, the measurement, apply system properties to the file and ultimately launch a and long a measurement
  5. Once this is working, launch the sample TestStand sequence file to call then framework from TestStand using custom step types

 

Extending or Customizing Measurements

The example measurement is installed by default to C:\ProgramData\Measurements

 

The included example only features one measurement, "Standard Measurement," which his a very basic implementation. However, it is possible to instantiate N instances of this type of measurement, which should cover most basic use-cases.

Reasons to override this measurement include:

  1. A custom measurement display is required when it is running
  2. A different interface is required for specific devices (all acquisition in this example uses "read N samples from N channels" for acquisition and "write N samples for N channels" for generation
  3. A specific measurement or enrichment operation is desired to be added to the data as it is acquired and included within the log
  4. A safety-critical measurement needs to be performed on the data (perhaps on an RT system) that is responsible for closed-loop control (ie: safe shut down)
  5. Measurement requires that a specific type of device be specified, which can be defined by overriding the method to request hardware

Extending or Customizing Hardware

The example measurement is installed by default to C:\ProgramData\Hardware

 

Unlike previous versions, all devices inherit directly from the base Hardware.lvclass object. The measurement device implements the acquisition and generation interfaces. Device plugins wrap specific drivers and are called used a basic "Configure --> Acquire --> Generate --> Measure --> Repeat until Close" sequence. A device can specify specific interfaces that they implement if requested by the framework, but the default is for a device to support "all" interfaces.

 

All devices have both common and unique configuration options. The common capabilities are stored in the base "HW Configuration.lvclass," but extended by their own implementation for unique properties

 

Future Updates / Known Issues

  1. Remote execution of measurements on RT target (available in previous 3.0 version)
  2. The ability to launch one central logger instead of a logger per measurement
  3. The ability to launch the results from the measurement window
  4. Distribution of plugins with SystemLink as NIPM packages
  5. Devices have to be selected in error or then framework returns an error
  6. The path to store logs has to be valid, or framework return an error
  7. Various performance improvements when acquiring

Additional Information

The following articles describe core design decisions of the original framework:

 

This framework is not officially supported by NI, but will continue to be improved and developed based on input and feedback. The original version of this framework was published in 2012.

Elijah Kerry
NI Director, Software Community
Comments
onnodb
Member
Member
on

This is an extremely useful example of an application of the Actor Framework! Thanks so much for making this available. It helps a lot with understanding the AF, and some good practices for handling a large measurement application.

Science & Wires — a blog on LabVIEW and scientific programming
http://scienceandwires.com
Elijah_K
Active Participant
Active Participant
on

Glad you like it onnodb! 

Elijah Kerry
NI Director, Software Community
Olivier-JOURDAN
Active Participant Active Participant
Active Participant
on

Thank you for the quick fix Elijah. Everything works fine now.


Olivier Jourdan

Wovalab founder | DQMH Consortium board member | LinkedIn |

Stop writing your LabVIEW code documentation, use Antidoc!
Ben_Engelen
Member
Member
on

This is a really nice example!!, will certainly have a detailled look at it.

Elijah keep up the good work!!

onnodb
Member
Member
on

Works like a charm! Thanks!

Science & Wires — a blog on LabVIEW and scientific programming
http://scienceandwires.com
GoofyWires
Member
Member
on

Hi Elijah,

First let me say that I love everything that you are posting!

I'm working on a MVC version for very large spaghetti app:

http://lavag.org/topic/15331-mvc-through-class-control-feedback-required/

The main difference in my general approach is that most of the LVOOP I see around requires a complete redesign while most companies don't have the time or money for that.

However, beside upgrading old code I'm working on some new code and I try to work with all the best practices I learned from your posts.

Now for this amazing post (HAL, MAL... what's next? PAL - programmer abstraction layer?):

I'm using newer versions of all the vimp packages you require and I thought that it is ok but now I see that it is working for other.

Besides that, everything looks great and I can't wait to play with the full version and post back my feedback and gratitude.

I have already implemented HAL and UI Framework using LVLibP based on https://decibel.ni.com/content/docs/DOC-15014 and https://decibel.ni.com/content/docs/DOC-19176

Now I'm trying to implement MVC in the lower level of a single module inside a LVLibP.

I'm using the class control as the Model, a vi FP as the View, and another vi BD as the Control/Logic. The main trick behind my implementation is a recursive vi that scans the View for all it's controls and allows a direct access by name or reference, thus, allowing, if I understand correctly, communication with less classes and coupling (in the state machine you need to know the name of the command and a class to cast it into while I only need the name of the control to be the same as the control mirror in the class) to the View.

However, even though I think my View and Model are inherited a bit better in my design (the lavag version is old and dirty but you can see the general approach) your logic is inherited much better than mine and I love the MAL.

This is not the only reason I prefer to use your code, I tend to prefer official implementation since there are many people debugging the code and there are updates from time to time with great documentation + a forum you can ask questions about a common tool.

Any chance you can compare our approaches and the other one I heard that is coming soon?

Keep on the great work,

Dror.

P.S. - I followed each of your posts since I read a post of yours that made me understand: here is someone that knows how LV looks underneath. It was something about why certain things can't be dynamically dispatched since the operation won't be atomic and a child and a parent will try to access the same data. Since then I hear your name everywhere, from G# to every OO field I'm getting into. Thanks for everything!

Elijah_K
Active Participant
Active Participant
on

Thanks for the kind words GoofyWires.  The issues you mentioned regarding missing dependencies were quickly resolved, and I removed the notifications from multiple users.  Please download the latest version above and let me know if you continue to have any problems.

I do not use or test my slides in Open Office, but I do make extensive use of multiple objects that likely do not translate correctly.  Just in case this is a recurring issue, I've uploaded the slides as a PDF.

Finally, I will download a copy of your application to review in the next few weeks, but I'm about to embark on several weeks of travel, so it may take some time.

Elijah Kerry
NI Director, Software Community
TroyK
Active Participant
Active Participant
on

Wow, thank you very much for this great information and example.

The third slide in your presentation makes me feel ill if I look at it too long. I'm convinced! No more disturbing pictures please .

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
Elijah_K
Active Participant
Active Participant
on

You're welcome!  Regarding slide 3, it has become my universal problem statement for most of my presentations - I've decided to rotate the block diagram annually (I have no shortage of examples).  I always ask, "how many people have inherited code like this and been asked to add a feature or fix a bug?  No big deal... right?" 

Elijah Kerry
NI Director, Software Community
GoofyWires
Member
Member
on

It is working great now. Thanks!!!

A few questions:

1. How do I open the block diagram of the actor? I tried using http://zone.ni.com/devzone/cda/epd/p/id/4008 but I can't even see main.vi there.

2. How did G# help you with the actors? Will the project work for someone without G#?

3. The results view works just for the diode. Frequency+Resistance tests fail (guess they should but I can't see the graph in view) and strain doesn't show up in the results window at all.

Once it will be working I'll turn the plugins into lvlibps and test how does the AF communicate between exe and lvlibp. If you know the answer already please let me know.

Besides that, it is fast, clean and beautiful!

Dror.

Elijah_K
Active Participant
Active Participant
on

1. I'm not sure I understand your question, as an actor is represented by a class. The methods of the class define the messages and actor can handle.  These are processed within actor core.  For the most part, only actors with a UI have a custom implementation of actor core.vi.  You might be looking for the block diagram of the Operator UI, which can be found under the Operator UI.lvclass in actor core.vi.  If I misunderstood you, please clarify what it is you're trying to see.

2. I like G#, but I did not use it for this project

3. If a custom result is not defined for a measurement, it will just show the default display for results.lvclass, which is just a graph and a pass/fail boolean.  This display can be customized by overriding it in a child of the results class.  Very few measurements have a custom display at this point - I would like to add more over time.

Elijah Kerry
NI Director, Software Community
GoofyWires
Member
Member
on

1. It is a general problem I have while debugging call by ref of a  reentrant vi: I want to see the actor core during run. However, you can't step into a call by ref (and most of the time LabVIEW will hang saying it is resetting the paused vi and the only solution I know of is to kill LabVIEW) and you can't open in advance the actor core since it is a reentrant vi and another clone will be opened. Even debug application or shared library didn't help me. The best that I can do is add to each vi called by ref a request to open the block diagram. I thought the tool I mentioned will help me yet it didn't. Is there an easier way?

2. I thought that I recognized the actor and the msg icon is the one from G# interface. Moreover, for some reason the first time I run the project I had some G# items in memory. Probably some kind of glitch on my side.

3. I see.

Playing with the design some more I must say that it ties together most of the new practices out there.

I even added functionality and it wasn't hard at all.

Thanks.

AristosQueue (NI)
NI Employee (retired)
on

GoofyWires:

Regarding #1: In LV 2012, we provide a way to open the VI from Launch Actor.vi, which helps a lot with this debugging.

Regarding #2: Nothing from G# here. 😉

> I even added functionality and it wasn't hard at all.

Good. That's the goal. 🙂

Ian_Phillips
Member
Member
on

Excellent ... I am finally starting to understand how powerful OOP is.

Just a quick note:

The MAL.zip file in the download links at the top of the post refers to the older file and has some vi's missing.

Download the correct version from attachments at bottom of post.

Ian_Phillips
Member
Member
on

Is there a recorded webcast of the presentation available, I did a quick search but couldn't find one.

Thanks a gain.

Patur
Member
Member
on

Thanks for the download tip @IanPhillips ...

--
Patur Sivertsen Vase
www.hfjensen.dk
Thoric
Trusted Enthusiast Trusted Enthusiast
Trusted Enthusiast
on

Ian, I've heard from Elijah that he plans to create a webcast of the presentation soon...

Thoric (CLA, CLED, CTD and LabVIEW Champion)


QFang
Active Participant
Active Participant
on

a recorded webcast with the demo's would be awesome!!

QFang
-------------
CLD LabVIEW 7.1 to 2016
edisler
Member
Member
on

Am I missing something, where is the MVC and MAL example project. It doesn't seem to be in the Actor Framework folder?

QFang
Active Participant
Active Participant
on

Just scroll up on this page, under the "attachments" section. Download the files you find there. (I already had v3 of the Actor framework installed along with everything else, so I got away without applying the vipc file).

QFang
-------------
CLD LabVIEW 7.1 to 2016
edisler
Member
Member
on

Never mind, I confused the MAL.zip with MAL.vipm

Elijah_K
Active Participant
Active Participant
on

The current plan is to post a webcast presentation by May 16th.  I'll be sure to let this group know.

Elijah Kerry
NI Director, Software Community
QFang
Active Participant
Active Participant
on

I just posted up a question related to planning an MVC application (and sequence diagrams) in the NI forum. It seems like it would be good to link to it from here, but if this type of cross-linking is discouraged, I appologize!

In general, if I wish to discuss large app topics, is it recommended to post in this group somewhere or is the forum the best place to do it or start in? (I'm somewhat of a "community noob" outside of the forum.. ) Here is the post http://forums.ni.com/t5/LabVIEW/UML-Sequence-diagrams-and-MVC-planning/td-p/1944387

QFang
-------------
CLD LabVIEW 7.1 to 2016
AristosQueue (NI)
NI Employee (retired)
on

Generally, just post the question in one place and only post the link if you think that the discussion is relevant to both places (making sure that you specify that the discussion is taking place in the other thread). If you're not convinced that the discussion is relevant to both places but you're only trying to get lots of people to read it so that you get help, generally, I just post to one forum, wait a couple days, and only post elsewhere if I don't get any responses.

gbecker
Member
Member
on

What is the recommended way for the main.vi lifetime for an actor framework based program like this?

With supplied build config, I get an exe which when I click "Run UI", either closes directly since the main.vi closes before the UI comes up or the UI shows a second and the runtime closes with a Visaul C++ error R6025.

When window close in the main.vi is delayed for e.g. a second it seems to work, but that just not nice. Using window hide instead of close leads to a not exiting application.

Elijah_K
Active Participant
Active Participant
on

Gbecker,

You have stumbled across a known issue in this version of the Actor Framework and how I wrote this application.  In summary, there is a split-second between the launcher terminating and the Actor spinning up when no VI's UI is open.  When this happens, the RTE considers open references invalid and you see the behavior you experienced.  The easiest fix is to put a small delay in the launcher VI to ensure that it does not terminate before spinning up an actor.

This issue will be addressed in 2012 and the version of the Actor Framework that we are shipping in the product.  I also plan to post a new copy of this application with that problem addressed.

Hope this helps,

Eli

Elijah Kerry
NI Director, Software Community
Elijah_K
Active Participant
Active Participant
on

Update: I have posted a new vipc file, which includes the latest version of the dependencies (inlcuindg AF 3.0.7.14) and an updated copy of the code that can be built into a working executable.  Let me know if you have any other problems.

Eli

Elijah Kerry
NI Director, Software Community
AristosQueue (NI)
NI Employee (retired)
on

Goofywires wrote:

> What's next PAL - programmer abstraction layer

Actually, PAL is the acronym for something that National Instruments makes and you probably have installed. It's the Platform Abstraction Layer, to take care of differences between the machines you use for running your tests. It is unlikely that you would need to write a PAL of your own. But you might find yourself writing an ALAL if the component you're using has an AL but you're facing the possibility of changing components. 🙂

Remember the old admonition: Most problems in computer science can be solved with another layer of indirection. 🙂

Daklu
Active Participant
Active Participant
on

AristosQueue wrote:

Most problems in computer science can be solved with another layer of indirection. 🙂

Except too much indirection. 

AristosQueue (NI)
NI Employee (retired)
on

Daklu wrote:


                       

AristosQueue wrote:

Most problems in computer science can be solved with another layer of indirection. 🙂

Except too much indirection. 


                   

That's not a problem in computer science... that's a problem in computer scientists.

TwymanPlumb
Member
Member
on
Could we get an installation that does not use VIPM,, long story short, compancy policy against using it or any program needing to be run as admin.
Elijah_K
Active Participant
Active Participant
on

I'm afraid that the dependencies are all VI Package Files, so that would be a non-trivial task.  The good news is that VI Package Manager will be included with the Platform DVDs in August, which may address some of the problems you currently face when installing third-party software.

Elijah Kerry
NI Director, Software Community
vishots.com
Member
Member
on

VIPM does not need to be run with Admin access. Please try VIPM 2012.

B.Settles
Member
Member
on

That little tidbit of information is awesome...

"All truths are easy to understand once they are discovered; the point is to discover them." -- Galileo Galilei

Elijah_K
Active Participant
Active Participant
on

Finally have a webcast recorded on this application.  If you're interested, you can watch it here: http://zone.ni.com/wv/app/doc/p/id/wv-3364

Elijah Kerry
NI Director, Software Community
SJ_Buddy
Member
Member
on

Hi Eliah,

Could you, please, upgrade your MAL projecct to 2012 if you have time.

Thanks,

Elijah_K
Active Participant
Active Participant
on

Buddy, absolutely!  In fact, I'm getting ready to roll out a new version with several improvements that I'm very excited about.  In addition to re-linking the code to the AF in 2012, I'm packaging all of the source for 2012 in a VIP file that installed the framework and a templatized measurements into the 'Create Project' dialog of 2012. 

I'll go ahead and post a version for 2012 right now, but keep in mind that I plan to continue to refine and update the code - the good news is that since it'll be a VIP file, it'll be much easier to update as new versions become available!

UPDATE: Posted!

Elijah Kerry
NI Director, Software Community
elset191
Active Participant
Active Participant
on

I'm assuming it is non-trivial to convert this code to 2010?

I have a few design questions regarding a project I have coming up using a cRIO.  I'm assuming it wouldn't be the best idea to have each channel be a measurement, but rather reading all the channels and then distributing the values accordingly once they're read in.  This way I know that each sample has essentially the same timestamp, and I don't have to loop over every channels every time I read (pretty much continuously).  Therefore would my cRIO (or each module?) be a child of measurement?  Instead of having say 10 pressure measurements, 5 temperature measurements, etc.  I'm assuming then that my controller would have to know which channels belong to which physical instrument.

Is there a better, more established way to do this?

--
Tim Elsey
Certified LabVIEW Architect
TwymanPlumb
Member
Member
on

Elijah

After installing and reinstalling your Measurement Utility and creating a new sample project, the project is missing the document. I am a newbe on the Actor Framework and trying to understand how to use it, so all documentation is greatly appreciated.

Keep up the great work

Twyman

Elijah_K
Active Participant
Active Participant
on

Which document are you missing?

Elijah Kerry
NI Director, Software Community
TwymanPlumb
Member
Member
on

Measurement Utility Script.doc specifically.

Thanks

Elijah_K
Active Participant
Active Participant
on

Ah, I'm afraid that's just a placeholder for now.  I'm working on it!

Elijah Kerry
NI Director, Software Community
RENN
Member
Member
on

Great work!! thanks a lot

Kudos always welcome for helpful posts 🙂
helcio
Member
Member
on

I cannot find where is the project file for the MVC presentation. I thought it would be included in the national_instruments_lib_measurement-1.0.0.23.vip, but not. Does nomeone knows where I can get the project file together with all the files that makes part of the Elijah's MVC actor framework example?

thanks

Elijah_K
Active Participant
Active Participant
on

It should be included in the project that you open from the 'Create Project' dialog once this package is installed.  You can also download the slides directly under the 'attachments' section above.

Elijah Kerry
NI Director, Software Community
spincraft
Member
Member
on

Loading the AF 4.1.1.33 using VIPM inside LV2012, opening the WebActor.lvproj file then Build All from the Build Specifications yields;

An error occurred while saving the following file:C:\Program Files\National Instruments\LabVIEW 2012\vi.lib\ActorFramework\Actor\Launch Actor.vi
Error 1502 occurred at AB_Source_VI.lvclass:Close_Reference.vi -> AB_Build.lvclass:Save.vi -> AB_Build.lvclass:Copy_Files.vi -> AB_Application.lvclass:Copy_Files.vi -> AB_EXE.lvclass:Copy_Files.vi -> AB_Build.lvclass:Build.vi -> AB_Application.lvclass:Build.vi -> AB_EXE.lvclass:Build.vi -> AB_Engine_Build.vi -> AB_Build_Invoke.vi -> AB_Build_Invoke.vi.ProxyCaller

Possible reason(s):

LabVIEW:  Cannot save a bad VI without its block diagram.

Your insights are welcome.

Thanks!

Elijah_K
Active Participant
Active Participant
on

This app was built against the version of ActorFramework that is shipped in 2012 - you shouldn't need to install 4.1.1.33.  Granted, it shouldn't cause any probelms to have both installed, but I suspect it may be related. Try uninstalling the Actor Framework from VIPM and create a new instance of this app from the Create Project dialog.

Elijah Kerry
NI Director, Software Community
spincraft
Member
Member
on

Thanks, that works as advertised. Best!

NI-hilator
Member
Member
on

Q1: I am using Labview 2012 which includes the actor framework.  Will installing "national_instruments_lib_measurement-1.0.0.23.vip" cause a problem? i.e. How do I check the version of the actor framework that is currently installed?

Q2: I did read @edisler's and @QFang's posts about the MVC and MAL example projects, but I still don't see any example project files in the attachement section.  All I see is the vip package, which according to the note preceding only includes the actor framework, ppt and pdf files. 

Elijah_K
Active Participant
Active Participant
on

A1: No - it is actually built against the AF that ships with 2012.

A2: This vip file will install the demonstrations to the create project dialog that illustrate MVC and MAL. 

Elijah Kerry
NI Director, Software Community
Contributors