LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to contnsly access the subvi

Hi everybody,

          Here i uploaded the code to access the two different subvi from main vi once i opened and closed i can't able to open it again.

    The main contains a file path and boolean button to open a subvi. The subvi one consists of user data and subvi 2 consists of process window to display the acquired data and log the data in a specified file, here i used event structure to access the subvi and pass the refnum of the file path using queue functions but i don't what is blocking to access both vi's? continously, here i need your help to go further for clarification.

Thank you in advance,

regards,

paul robinson

Download All
0 Kudos
Message 1 of 14
(3,199 Views)

Both SubVIs have while loops with a "stop" button inside of them, are you stopping the SubVIs? You cannot run the SubVI with new inputs until it has completely finished executing, meaning the while loop has stopped.

 

Also, I'm not sure what you're trying to do with the 2 event structures in your Main VI. Everything can go in your top loop, or if you prefer, include an enum or string with your queue data to select the case of a case structures, but don't use a second event structure. Your UI will lock up whenever the event structure is executing.

 

0 Kudos
Message 2 of 14
(3,193 Views)

Looking at your code, it appears that you really need to go and review some of the first Principles of LabVIEW, probably obtainable by carefully paying attention to the first view Video Tutorials that are mentioned on the first page of this Forum.  Here are some issues you should consider:

  • Understand the idea of Data Flow, the Central Concept of LabVIEW.  Among other things, this says that if you have a sub-VI that runs and never exits (such as SubVI 1), the calling program will "block" (as it is waiting for the sub-VI to exit).
  • Understand how a While Loop works.  If it is controlled by a Stop indicator, it will not exit until the Stop Indicator becomes True.
  • Understand that "ordinary" sub-VIs do not give the caller access to the Front Panel.  In particular, without some advanced coding, you cannot push the Stop button in SubVI 1.  Hence, by the previous two points, your Main code will "get Stuck".
  • Understand the "usual" (meaning in 99.5% of the cases) way to use Event Structure, including the "general principle" that there is only a single Event Structure inside a single While Loop.  Given the previous point, is it obvious why Event Loops are almost never found in sub-VIs?  [Hint -- what is the most common class of programmed Events?]
  • Many of the above comments that apply to SubVI 1 also apply to SubVI 2.  In particular, none of the Boolean "buttons" on its Front Panel can be "pushed", so they will all (forever) have their default value of "False" (unless you push them on the Front Panel before you start MainVI).  Do you now understand why this is the case?

Here's what you need to do.

  • Redo MainVI as follows:
    1. Have a single Event Loop.
    2. Put all of the Controls that require User Interaction on the Front Panel.
    3. Think about what logic you might need (for example, can you press Controls in any order, or do you need to "ignore" button presses until a certain point in the code).  See if you can come up with ways to accomplish this.
  • Redo SubVI 1 and SubVI 2 so that, when called, they do "one thing" and then return.  Check that all Controls and Indicators on their Front Panels correspond to Parameters you pass In and Out, and make sure they are wired to the Connector Pane.  Similarly, make sure that MainVI is connected to all of the Connectors (unless you intend to use the Default values).

When you've made the necessary changes, try your code again.  It will almost certainly run better, and do "what you want" instead of "what you told it to do" (it should always do the latter ...).  Feel free to ask more questions.

 

Bob Schor

0 Kudos
Message 3 of 14
(3,150 Views)

Hi gregoryj,

    Here i listed what i really wanted to do:

    1. From main vi i need to access sub vi at any instant.

    2. I need to append the user details in a same data logging file.

I just need some guide to know which way it will works i am new to this labview but i have basic understanding, anyway thanks for the reply.

 

Regards,

Paul

0 Kudos
Message 4 of 14
(3,110 Views)

Hi Bob,

          Thanks for your reply and i re-edited the code using QMH it works much better know but i have little problem here, when i press the file specify button and again if i close without specifying the path of the file it shows error and also i tried using simple error fuction with no dialogue it still shows the error message dialogue box everytime and also it shows same for promt user when i open it without specifying the file path and it shows error after i closing it, any solutions you got for this?.

Thanks in advance,

regards,

Paul

Download All
0 Kudos
Message 5 of 14
(3,089 Views)

You'll need to check the file path after asking, if it's empty or Not A Path you cannot use it to write to file, send up a one button dialog informing there's no file chosen instead.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 14
(3,078 Views)

Hi yamaeda,

    First of all thanks for your reply,but i really didn't get it, can you please explain me briefly? and sorry for the excuses.

Regards,

Paul

0 Kudos
Message 7 of 14
(3,062 Views)

Hi yamaeda,

           I tried using your idea but it is not working well you have any other solution to get out of this problem.

Thank you,

regards,

Paul

0 Kudos
Message 8 of 14
(3,039 Views)

You are using LabVIEW 2013, the last version of LabVIEW to use Read/Write to Spreadsheet File, replacing it with Read/Write Delimited Spreadsheet, whose main difference was the presence of the Error Line in the lower left and right corners (something that NI overlooked for too many years).

 

With the Error Line in place, calling these functions with a "bum argument" (for instance, failing to specify a legal filename to write) will generate an Error on the Error Line, which you can write code to "trap" and figure out what you want to do (like clear the error, output a Dialog box that says "Oops, you forgot to specify the output File Name" and do the whole process in a loop that exits when either there is no error or the user chooses the "Give Up" option to terminate the program early).

 

However, you don't have an Error Line on this function, so an error just causes the program to "blow up in your face".  What you need to do is to anticipate and prevent errors.  Since the most common error is a missing or otherwise illegal file name, you can ask if the File Name meets certain specifications (like "is not Empty" or "is not <Not a Path>") and take appropriate actions depending on the outcome.  That's what Yamaeda was suggesting.

 

Bob Schor 

Message 9 of 14
(3,032 Views)

Thank you Bob, that was what i meant.

I could be something easy, like this:
File check.PNG

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 14
(3,011 Views)