Jump to content

MUX - vi scripting a case structure


Jubilee

Recommended Posts

I find nested cases to be cumbersome and hard to debug.

Thus, I prefer having a single case structure with all the different complex cases I need.

For example, instead of having two case structures one inside the other with the first if (a=true) and inside it another case structure if (b=false) I want a single case structure with if (a=true & b=false).

Moreover, I want the different cases of this case structure to be filled automatically.

I attached a vi that does exactly that by turning a ring with the inner cases into a constant enum and connecting it to the case structure to fill the initial values into the case structure.

Then, I entered the different Boolean inputs into a formula node to decide which case I'm handling and connected it's output into the case terminal.

Since the formula node handles numeric value I had to convert it into the right string value before I entered it into the case.

Once the vi is initialized the user copies the created case structure that is disabled into the calling vi.

I'm trying to learn scripting to automatically do the next steps:

1. read a text file with the input variable names and the cases we want to create and automatically enter the data into the formula node (change input labels according to the input variables and the equations as the text inside the formula node)

2. input the different cases from the user's text into the ring control and initialize the case structure values

3. add additional inputs and expand the existing code automatically

In the future, instead of having the user/programmer enter the formula there might be a window with options like in outlook's contact list selection panel to help create the different cases by marking the elements and relationships in each case.

Since I'm relatively knew to LabVIEW I would love some input/help. Is that the right way to do it or should I use some other tools like express vi and polymorphic vis for example?

Thanks in advance,

D.

P.S. - the formula node is efficient and turning it into a subvi makes it a bit less efficient. Is there a way to collapse some code on the block diagram into a single block visually without turning it into a subvi?

mux.vi

Link to comment

Thanks.

Yet, the working example there is based upon xnodes. Wasn't it deprecated long ago? How do I use xnodes?

I love the idea yet I'd prefer implementing it over regular vi scripting.

Should I use xcontrols? Is it ok to use it inside a commercial product?

I took a look at JKI Right Click Framework, will it suite my needs?

Link to comment

Wasn't it deprecated long ago?

No. Those were external nodes. XNodes are fine.

How do I use xnodes?

Don't know. There's no proper documentation (since it's not an officially supported feature), but you can look through the
LV
wiki or look at actual example. Basically, you should have VIs which are called when specific events occur (such as when the user wires something into the node).

Should I use xcontrols? Is it ok to use it inside a commercial product?

XControls are fine and officially supported. XNodes are not officially supported, but that does not mean they won't work, just that you won't get official support from NI if they don't work and that they might change between versions. Personally, I probably wouldn't use my own XNodes in commercial apps unless it was really necessary.

I took a look at JKI Right Click Framework, will it suite my needs?

I don't know. The RCF allows you to invoke specific plugins on the code you select. You could probably write a plugin which does what you want, but I didn't look at your actual code.

Link to comment

Thanks Yair. I still have no clue as for xnode and xcontrol yet the scripting is finally on, had to activate it through tools->options on LV 2010. I'll post here the final code.

Yet, since the other implementation (which looks great and is exactly what I meant - great work guys) is closed and uses xnodes I still ask for help about my design which can be very similar to the design they decided on but without xnodes unless someone can show me a tutorial.

Besides that, is there a way to colapse code into a single block without turning it into a sub vi?

Thanks in advace,

Dror.

Link to comment

I don't think that the code there is locked. If I remember correctly, you can open the specific VIs in that XNode and look at their code. You can find another example here (and in other posts Darin made), but I don't think you'll find a full tutorial anywhere. At the moment, if you want to use XNodes, you will probably need to hunt down the information yourself.

You can't collapse code without using a subVI, but there is a shortcut - select the code you want and select Edit>>Create SubVI. You can see more on this in this discussion - http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Allow-Hide-Unhide-of-code-inside-Block-Diagram-without-using/idi-p/1495972

Link to comment

Hi Yair,

It took my some time to get there but I finally caught up with you.

The XNode works just fine. No, not just fine, it is awesome man! It is justwhat I imagined in functionality and even better than what I imagined as forthe way it looks and works.

Thanks Yair! You and the one who wrote the damn thing are the best!

I'm going to study those examples now so I could do magic too :)

As for the collapse option, it seems like any good idea I have someone thoughtof it before I did and I'll have to search lava better next time.

Hope to pay you back someday soon and maybe even publish back an XNodetutorial.

Take care,

Dror.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.