LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
FermWorks

Implement conditional logic in Parse & Eval Formula Node VIs

Status: New

I wish the Formula VIs supported conditional logic.

 

More broadly, make the Formula Node and the Formula Parse and Eval VIs have the same syntax and capability.

 

from LV help:

Differences between the Parser in the Mathematics VIs and the Formula Node
The parser in the Mathematics VIs supports all elements that Formula Nodes support with the following exceptions:

Variables—Only a, a0, ..., a9, ... z, z0, ..., z9, are valid.
Logical, conditional, inequality, equality—?:,, &&, !=, ==, <, >, <=, and >= are not valid.
Functions—atan2, max, min, mod, pow, rem, and sizeOfDim are not valid. You can use these functions in a Formula Node or use their corresponding LabVIEW functions.

 

11 Comments
altenbach
Knight of NI

The big difference is that formula VIs are interpreted at run time. (you can change the formula via a string control at any time!). You can look inside and see that all the parsing is implemented directly in LabVIEW code. The formula node is compiled at edit time and thus very efficient.

 

Inspecting the code of the formula VIs, you can see that it is ancient and looks pretty stale. (e.g. is was written before index array was resizeable!)

 

Not sure if it is worth implementing big changes in the formula VIs. Their use is pretty limited and performance is not great.

 

If you need fancier text based math, NI has developed Mathscript RT.

FermWorks
Member

Yes, MathScript would be great, but is there a way to give it a script at run time? That's the reason I'm using hte formula VIs, for changing formulas.

Thanks.

 

SteenSchmidt
Trusted Enthusiast

You might be interested in this toolset GPower is about to release (within a month is our goal):

 

Palette.png

 

From the VIP description:

 

"This toolset enables you to programmatically create mathematical expressions as strings and evaluate them into numeric values at runtime. For instance: "SIN(x)/2-COS(x)/2" where x=pi -> 0.5

 

Most of the solutions built into LabVIEW for math expression evaluation force you to define a static expression at edit-time which you can then evaluate for different variable values, for instance textual expressions with a Formula Node or with discrete math building blocks like Add and Multiply. The built-in Formula Node performs very well but is obviously limited to a static mathematical expression. Using discrete math building blocks performs just as well but is really unreadable for all but the simplest of expressions - and are obviously also statically defined.

 

There is a third built-in option, Formula Parsing, that compares better to the GPower Expression Parser in terms of functionality, in that it lets you parse and evaulate a string-based math expression and thus at first glance alleviates the static  limitations of the Formula Node and discrete math blocks. The drawback with Formula Parsing is poor performance and limited function support.

 

GPower Expression Parser features
- Currently offers 4 times as many functions (beyond the ordinary binary operators) compared to Formula Parsing.
- Performs about 5x better than Formula Parsing (easily in the MHz-area).
- Broad variable support including accessing VI Registers directly from within an expression (evaluate your expression in one VI, and having it "wirelessly" depend on a piece of code in another VI entirely).
- Reports overflow if it occurs during evaluation.
- Supports all 14 numeric data types that LabVIEW offers, including complex evaluation, where the built-in options only support DBL.
- Offers special function control like conditionals, piecewise defined functions, pulsetrains, and defining your own custom cyclic functions."

 

Sorry to deliver a plug like this, but the case was so obvious...

 

Cheers,

Steen

CLA, CTA, CLED & LabVIEW Champion
FermWorks
Member

Steen, in this case, your plug is appreciated!  Do you have a beta version?

Also, could there be an even faster/cheaper/free version that is more limited, e.g. only works with DBL data type, only basic functions? (that's all I need!)

What will the price be?

(we can take this offline:  fwsupport@jovasolutions.com)

 

SteenSchmidt
Trusted Enthusiast

Jova: No beta, but I'll send you an email when an evaluation version will be available. Prices are not finalized yet, as this will be our first paid for toolset.

 

There will be faster versions with reduced functionality included in the final library, but I assure you that the full featured versions are lightning fast out of the box (it is a GPower toolset after all, and at GPower we go to 11 Smiley Tongue) But I thought you were asking for more features than the built-in Formula Parsing has, not just faster?

 

/Steen

CLA, CTA, CLED & LabVIEW Champion
FermWorks
Member

Yes, speed isn't the issue, it's features: the conditional parsing, in particular.

I was just hoping to get it sooner.  Smiley Wink

Thanks!

phil_prismtc
Member

Steen,

 

I too would be very interested in this toolset. I just checked and I couldn't find it through the LabVIEW Tools network 😞

I have been using your free toolsets and I am very pleased with the quality of your products. Could you please send me an e-mail as soon as an evaluation version of the Expression Parser toolset  is available?

SteenSchmidt
Trusted Enthusiast

Hi Phil,

 

Sorry for the late reply - we've just committed the Expression Parser toolset to final internal review for release, and a trial can probably be commisioned in a short while. Albeit such trial-code would be a manually assembled package not using the final licensing algorithm (the licensing scheme won't be finished until after the summer holidays, and after NIWeek at least). I'll see what I can do on short notice.

 

Cheers,

Steen

CLA, CTA, CLED & LabVIEW Champion
FermWorks
Member

Steen,

I'm also still interested in testing your toolset asap.

Can I get some preliminary documentation even sooner?

Thanks!

Meg

 

SteenSchmidt
Trusted Enthusiast

Hi Meg,

 

I can send you the Expression Parser User Guide, but I have no contact information on you. I've tried emailing your company at fwsupport@jovasolutions.com, but so far haven't received any response.

 

Please contact me at ssc@gpower.as, and I'll get back to you on that.

 

Cheers,

Steen

CLA, CTA, CLED & LabVIEW Champion