Discussion:
How can I programatically perform a conditional formula in "Eval Formula Node"?
(too old to reply)
markwysong
2004-09-10 14:52:05 UTC
Permalink
Okay, I'm stumped. I have an application where I need to evaluate a
conditional programatically, and I can't do it with a Formula Node.

Basically, my user wants to be able to enter some formula which
describes conditionals, such as "if this temperature goes above X
degrees or this temp goes above Y degrees, then take a reading" kind
of thing. Since the conditional will be saved in a file, the formula
node needs to be dynamic.

I've used the "Eval Formula Node" before, which is built for this type
of application...sort of. I tried it, but after trying in vain to get
it to work properly, found out that it doesn't do boolean and
conditionals in its parser, so it won't work.

Does anyone have a good idea how to do this??
markwysong
2004-09-10 15:59:51 UTC
Permalink
I think you misunderstood my question.

I am a seasoned LabVIEW programmer,and I know you can't interact with
hardware within a formula node. I was simplifying the explanation of
what I'm trying to do.

My customer wants to be able to input, at his discretion, trigger
points as to when data will be written to a file. Therefore, he wants
to be able to enter something along the lines of:

If temp1 > 200 or temp2 > 300 then write acquisition data to a file.

I'd create a formula node to handle the conditional, with a 0 or 1
coming out of the formula node, change that to False (0) or True (1),
and use that boolean to drive whether or not to write data.

However, the conditional is not the same for every test. Therefore,
using the formula node like you attached, is not the answer, as I
stated in my first post. With that formula node, you have to
pre-define the inputs, outputs, and formula; I can't do that.
Therefore, I need to use a VI called "Eval Formula Node", which allows
you to dynamically enter the inputs, outputs, and the formula.

The Eval Formula Node VI doesn't allow the use of conditionals
(greater than, less than, equal to, OR, AND, etc), so now I don't know
how to solve this.

Hard coding the wiring into LabVIEW isn't an option, since there are
so many combinations that could occur, it would be impossible.
altenbach
2004-09-10 17:35:05 UTC
Permalink
Sorry I misunderstood. Now it's a bit more clear what you want to do.

You might just be able to use a plain string input and write your own
simple parser. How complicated are the "formulas" (e.g. just one or
two comparisons linked with AND or OR or complex boolean constructs
with multiple levels of parenthesis, etc.)?

Most of the "Eval Forumal Node" is pure LabVIEW and it should be
possible to reduce it to something that works for your problem.

Personally, I don't like to have users enter formulas. The chance of
mistyped variables, syntax errors, etc. is just too big. Couldn't you
have a graphical front panel, e.g. a cluster for each variable
[Ring(Less|equal|greater,..); DBL(Limit); boolean(log|don't log)] or
similar?

Loading...