LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

error 1000 vi is not in a state compatible.."... dynamically loading vi with user-defined .m functions

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

 

0 Kudos
Message 1 of 6
(4,053 Views)
0 Kudos
Message 2 of 6
(4,008 Views)

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!

0 Kudos
Message 3 of 6
(3,997 Views)
Where are the .m files stored on disk? Are they in the same directory as the project associated with your Main.vi? Perhaps there is a location of dependency issue at play.
 
'Managing Dependencies in LabVIEW Projects'
Message 4 of 6
(3,967 Views)

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.

 

0 Kudos
Message 5 of 6
(3,922 Views)
Interesting. Well, if you find a conclusive solution, please post it on the thread.
 
Also, if you feel so inclined, you can write an example program to upload to the Community for others to see and develop from.
 
Best of luck!
0 Kudos
Message 6 of 6
(3,895 Views)