10-13-2015 10:46 AM
I have a set of predefined .m functions in a few vis.
Based on an input string, I am trying to dynamically load one of those vis with a mathscript node calling some .m functions.
I can dynamically load and run a vi when there is no .m function. I am using Open VI Reference method to open and Ctrl.Val.Set to set values to a control. Open VI and Ctrl.Val.Set do not generate error. But when I try to Run VI, I get an "error 1000 vi is not in a state..". The VI with .m functions runs fine by itself. When I try to run it dynamically, it gives me an error. Is there something I'm missing?
Thanks for your help in advance
10-14-2015
12:17 PM
- last edited on
01-21-2025
10:35 AM
by
Content Cleaner
10-14-2015 02:43 PM
Thanks for your reply..
I've seen this thread, one of them suggested
"However, there is not much to it. Use the "Open VI Reference" function that has a path to your VI with the Matlab Script in it. The VI will have inputs and outputs (must always be the same no matter what VI you dyamically load) that match the inputs and outputs to the Matlab Script. After the VI has run, close the VI reference."
This is exactly what I did, my "open vi ref" in Main.vi has a path to sub.vi. Sub.vi has a Mathscript node with matlab function. If Mathscript node contains matlab code without user defined function, everything works fine.
Here is what I am trying to do:
I have all .m files in a predefined folder. Some body else in the group or I will update these .m files keeping function names and arguments constant.
I would like to keep Main.vi running and load Sub.vi dynamically when needed. Ideally, I would like MathScript node in Sub.vi pick up the .m file from the predefined path when called. There are no FP user interactions for the whole process. Please let me know if my explanation is not clear.
Thanks again!
10-15-2015
04:30 PM
- last edited on
01-21-2025
10:36 AM
by
Content Cleaner
10-21-2015 11:15 AM
yes, .m files are stored on disk. I started with a new vi and tested with basic matlab functions. It seems to work.
The old non working vi had outputs in a cluster and the new vi has them in a 2D array. Except for this, there is no difference between vis.
I am still not sure why labview gave this error 1000 on Run VI. I need to do some more test to find out why the old one was not working.
10-22-2015
10:52 AM
- last edited on
01-21-2025
10:36 AM
by
Content Cleaner