01-17-2017 01:39 PM
I have a set ot TDMS files which represent raw data collected from various sources. What I do is offer my users the ability to define polynomial transforms of the raw data channels or of other polynomial transforms (I call these derived channels). To do this, I recursively lookup channel names until I have all the polynomials needed to define any of my derived channels only in terms of a single raw data channel. Given that I rarely have more than three levels of polynomial transformations (ex: Raw voltage to calibrated data in user units such as torque, calibrated data such as torque to calibrated force) this is a fairly efficent way to go.
I'm now asked to add in the ability to define additional derived channels using formulas (To perform basic operations in an end user intuitive manner such as adding channels together, performing FFT, offsets, inversion, simple scaling). These formulas are supposed to use the names of either the original raw data channels, derived channels (As above), or other formula derived channels.
The initial thought to support this is to use the eval formula functions of the mathematics palette, but I'm not sure where to start. The formula parsing uses names (a,a0..a9,b..z,z0..z9) and there would obviously be some need to validate dependencies etc. Is there a general way to handle something like this in LabView? Or perhaps I'm thinking about this all wrong?
Thanks,
XL600
01-17-2017 03:05 PM - edited 01-17-2017 03:07 PM
Hi xl,
you might use the Eval function: then your "frontend" must do the parsing of the input and replace the channel names by allowed parameter names. Could be a lot of work…
To give an idea:
I implemented something similar: I programmed a library of allowed funtions (simple math, statistics like mean/min/max, "special" formulas from polynomial to material property databases requests, etc.) All the information needed by the user is given in a spec sheet.
The user has to obey some fixed formatting of the calculation formulas (example: "chan_4 = 128:chan_0;chan_1;chan_2" will add the current values of those 3 channels.) I too have to parse those formulas, but as the format is "engraved in stone" it's quite easy. (There's a reason I use a number to select the function to apply… :D)
Was a lot of work, too…
01-17-2017 04:43 PM
I have done something like this before using the Evail Multi-Variable Array vi. It assumed use of channel names based on an array I had. So an example would be
(([Channel 1] + [Channel 2]) / [Channel 3])^2
would work just fine. I also wrote a calculator-type GUI so I could force proper syntax.
I rummaged through my old code and grabbed a snippit as an example of how I did the parsing.
01-17-2017 04:59 PM
Good ideas! I'll study these approaches and compare that to my idea of trying to use labview formula parsing plus name substitution and expansion. Mostly, the difficulty I forsee is dealing with dependency trees and order of evaluation decisions. My polynomial solution seems trivial by comparison.
Thanks,
XL600