LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

User configurable "rules"/operators at runtime. Anyone have an example or idea of architecture/implementation?

I'd like to make a feature where users could setup rules for certain things at runtime. Let's say something like when Variable X >= 10. When the condition is met, it triggers something. I have some early rough ideas in my head but I'm not enamored with them of how to actually implement the parts where the user selects the variable, the operator, and the value of comparison. The first that comes to mind is obviously a case structure but there's something about that that feels short sighted in terms of extensibility or maintenance. Has anyone implemented such an architecture? Would love to hear some comments/ideas. To be clear, I'm talking about end users being able to create these rules at runtime, NOT in the dev IDE.
0 Kudos
Message 1 of 9
(1,364 Views)

I made something like this. It was a CSV scripting file for testing so you could modify the CSV file (typically in excel) then pass it to the LV program and have it run it. In this case I had a column that defined the method (or case) then the next few columns had variables for that case. In this manner the LV program would execute each row in turn. 

 

In the end there were about 7 columns that were used to define functionality for each executing row. 

 

Using this methodology the technicians were able to script tests in excel which they were comfortable with using. 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 2 of 9
(1,349 Views)

@DoctorAutomatic wrote:
I'd like to make a feature where users could setup rules for certain things at runtime. Let's say something like when Variable X >= 10. When the condition is met, it triggers something. I have some early rough ideas in my head but I'm not enamored with them of how to actually implement the parts where the user selects the variable, the operator, and the value of comparison. The first that comes to mind is obviously a case structure but there's something about that that feels short sighted in terms of extensibility or maintenance. Has anyone implemented such an architecture? Would love to hear some comments/ideas. To be clear, I'm talking about end users being able to create these rules at runtime, NOT in the dev IDE.

By the time you invest in doing that once and poorly you've realized that you should have created the sequence in TestStand. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 9
(1,342 Views)

Hi DoctorAutomatic,

 

I made a subVI, called it preferences and another subVI to read (initiate) and write (update) locally stored ini files at the start and the end of the code respectively.

 

At the start, I read all the configuration values and store it into an FGV. Then call preferences subVI when needed which then provides a front panel to update specific/ all parts of configuration values and update it into the FGV as needed.  Now you can use the values in the FGV at different parts of code as needed.

 

When closing the program, these values are then written to the same ini file to be used as default configuration values for next  call of the application.

 

I hope this made sense.

0 Kudos
Message 4 of 9
(1,338 Views)

I think Flexlogger has some functionality like this as well. It's been a few years since I looked at it though.

 

I believe you can create Flexlogger plugins to do anything complicated, or you can just control IO pins with simple rules. I could be misremembering though...

0 Kudos
Message 5 of 9
(1,337 Views)

@JÞB wrote:

@DoctorAutomatic wrote:
I'd like to make a feature where users could setup rules for certain things at runtime. Let's say something like when Variable X >= 10. When the condition is met, it triggers something. I have some early rough ideas in my head but I'm not enamored with them of how to actually implement the parts where the user selects the variable, the operator, and the value of comparison. The first that comes to mind is obviously a case structure but there's something about that that feels short sighted in terms of extensibility or maintenance. Has anyone implemented such an architecture? Would love to hear some comments/ideas. To be clear, I'm talking about end users being able to create these rules at runtime, NOT in the dev IDE.

By the time you invest in doing that once and poorly you've realized that you should have created the sequence in TestStand. 


I'm not trying to make a test sequence of any sort.

 

Not aimed at you but I wish LabVIEW/community wasn't so geared toward the stereotypical niche of electronic test equipment. Wish it was a little more general purpose. I simply have no need for TestStand and have never even touched an industrial grade DMM in my life (c'mon, what's a LabVIEW example project without a DMM HAL or something?) which makes me feel like I'm using the wrong tool for the job and should consider something like C# or java instead. That new subscription model might be the push I need. 

0 Kudos
Message 6 of 9
(1,266 Views)

I don't do any sort of electronic testing at all, and I find LabVIEW perfectly usable. TestStand isn't just for electronics testing, though of course it is good at it.

 

It's also quite hard to offer advice when you're asking how to make a program "trigger something when a variable changes". Do you want it to send an email? Turn on a valve? Shut off the computer? It sounds like you're doing some sort of test, and TestStand is good at running tests.

 

Then again maybe you're automating something? Maybe you're controlling an industrial oven, or a robot arm, or a positioning table, or a high voltage amplifier, or a DC motor (all of which I've personally done with LabVIEW ;)). LabVIEW is used at SpaceX for their launches. It's also used to control particle accelerators. Maybe you're using it for a self-driving robot.

 

The point is you literally asked the question "How do I make LabVIEW do something" with no further details, so it's going to be very hard to give you suggestions other than "Maybe look at TestStand or FlexLogger, both of which are designed to let end users do some limited scripting."

 

Heck, at this point we don't know that LabVIEW truly IS the best tool for whatever job you're doing. I'll bet you it can do it though 🙂 Maybe explain your vision for what the software will eventually look like, and maybe walk us through an example routine, and we can make some better suggestions.

0 Kudos
Message 7 of 9
(1,253 Views)

@DoctorAutomatic wrote:

Not aimed at you but I wish LabVIEW/community wasn't so geared toward the stereotypical niche of electronic test equipment. Wish it was a little more general purpose. I simply have no need for TestStand and have never even touched an industrial grade DMM in my life (c'mon, what's a LabVIEW example project without a DMM HAL or something?) which makes me feel like I'm using the wrong tool for the job and should consider something like C# or java instead. That new subscription model might be the push I need. 

Hmm, I understand, there are a lot of T&M people here as that what LabVIEW is great at. I have only worked on a few LabVIEW projects that were not directly T&M and most of those were T&M adjacent, like making a UI for a database that held test data. 

 

Well to your original question I think I misunderstood, I thought you were trying to let users set variables outside of the program (like in an INI file or something). If you would like users to set the variables on the UI that is no problem.

 

This is a simple VI that I made to grab scope traces off an old GPIB scope but it shows the idea. The user can define some math then when the program runs it will take the user input and apply it to the logic. In this case on some scope traces. So using a case structure works great for this. 

Jay14159265_0-1661468309914.png

Jay14159265_1-1661468415200.png

 

 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 8 of 9
(1,251 Views)

I think you will find this problem is more complicated than you might think, but that depends on the complexity of what you actually want, so it might help you to start with a couple of concrete examples and try to think them through.

 

You could implement this using your own simple language and parser, or you could try something like having the users write Python code and executing that, or you could do it entirely in LV, but with all of them, you will need to decide all kinds of things. For example :

  1. You want to operate on "Variable X", but you don't have named variables in LV, so you need some sort of mechanism for storing values by name (map, variant attributes, etc.) and do all the management of this.
  2. What happens when your variables have different types. Does ">" have meaning for a boolean? How about a string? What happens if you want a rule for checking the length of an array? Or maybe some custom comparison? It's possible you won't need any of those, but it's also possible you will.
  3. What about the operations to perform? Let's say these are plugin VIs. That would likely mean that they would need to have the same connector pane, but you would want custom data for different operations. A class hierarchy with a dynamic dispatch VI might be good enough, but might not be.
  4. What about things like rule preference? Do you simply do a top down check until you find a matching rule? Maybe some have a higher preference, etc.?
  5. You need to decide about the save format for these rules. How human readable/editable to you want it to be? How future proof, etc.?
  6. After all that, you need to decide about the editing UI for this. This could be something like Excel, but then the burden for formatting the data correctly lies on the user. You could do this in LV, but building a UI which has a dynamic number of elements which are different from each other can be tricky. You can see a crude example for how something like this can work here. Depending on whether different classes require different UIs (for example, if operation X requires the user to enter params), this can get complicated quickly.

 

If I wanted to this purely in LV (and I have done things along those lines, although not exactly this), I think I would it might require a few class hierarchies (maybe one for the data types, one for the checks and one for the operations), but if possible, I would probably try to limit it as much as possible (for example, decide that variables can only be numeric).


___________________
Try to take over the world!
Message 9 of 9
(1,215 Views)