Sima Posted December 21, 2011 Report Share Posted December 21, 2011 Using the formula evaluation VIs, you can setup a way for the user to enter the formula of his or her choice and calculate the result based on what the values are. The limitation is that these VIs don't support boolean operations like the formula node does or like manually coding the formula with a bunch of ANDs and ORs. If only the formula node could accept a formula to be entered at run-time. Does anyone know of a way that will allow users to enter formulas with boolean operations, such as y = a & b, that will perform a bitwise AND, for example? Thanks. Quote Link to comment
Tim_S Posted December 21, 2011 Report Share Posted December 21, 2011 Bitwise is the part that makes that more challenging as you could use multiply and add for AND and OR otherwise. I wound up using spreadsheet string to array, converting to RPN, then parsing through. It's not fast nor strait forward. I'm certainly interested if someone has a better idea. Quote Link to comment
Sima Posted December 21, 2011 Author Report Share Posted December 21, 2011 Looks like there may be hope using VI scripting. Has anyone used VI scripting to modify a formula node before? Trying to mess with that now... Quote Link to comment
hooovahh Posted December 21, 2011 Report Share Posted December 21, 2011 Keep in mind that scripting does not work in a run-time environment. Meaning it won't work on a system that has a built EXE running, it will only work in a development environment. Quote Link to comment
jcarmody Posted December 21, 2011 Report Share Posted December 21, 2011 Could you use Lab Python? I wrote a small example here. [edit - fixed link to original discussion in the NI Forum] 2 Quote Link to comment
jzoller Posted December 22, 2011 Report Share Posted December 22, 2011 I've used LuaVIEW for this as well. From the manual: Since part of the job of the Lua parser/compiler is to parse arithmetic expressions, Lua can be abused as an expression evaluator. I had a (mostly) binary decision tree that had an arbitrary set of rules that users could input to reach a manufacturing rework/binning decision. I used Lua for the original tests, but ended up building my own parser and evaluator directly in LabVIEW. Sadly, the company I did that for is now gone, and the code with it... but such code is possible, and not even that hard, if you don't mind getting all computer-science-like. I adapted my implementation from an elementary textbook, but the basic subjects for googling are evaluating postfix expressions, and converting infix to postfix expressions. Joe Z. Quote Link to comment
ShaunR Posted December 22, 2011 Report Share Posted December 22, 2011 There's an arithmetic parser in the Labview examples. It can easily be modified to include boolean evaluation (just search for "expressions" in the example finder) Quote Link to comment
jcarmody Posted December 22, 2011 Report Share Posted December 22, 2011 I just tried my Lab Python vi. Quote Link to comment
Tim_S Posted December 22, 2011 Report Share Posted December 22, 2011 There's an arithmetic parser in the Labview examples. It can easily be modified to include boolean evaluation (just search for "expressions" in the example finder) The arithmetic parser doesn't handle bitwise operations, or at least it didn't when I last looked. May have to look again... Quote Link to comment
ShaunR Posted December 22, 2011 Report Share Posted December 22, 2011 The arithmetic parser doesn't handle bitwise operations, or at least it didn't when I last looked. May have to look again... Like I said.... It can easily be modified to include boolean evaluation Quote Link to comment
Tim_S Posted December 22, 2011 Report Share Posted December 22, 2011 Like I said.... I stand corrected then. Thanks, good to know it does bitwise operations. Quote Link to comment
ensegre Posted November 26, 2012 Report Share Posted November 26, 2012 Passing by, I found this boolean parser on the NI site. It's neat because it works also in linux, but doesn't support variables which is a hindrance for me, because the workaround is to string-substitute variables and parse the formula at each evaluation, which has a performance hit. Enrico Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.