08-17-2015 12:11 AM
want to run a Vi from the main Vi , simultaneously with the Main Vi ,
I know i can do this via dynamically referencing the Vi , but the issue is that both the Sub Vi and Main Vi have buttons to register different events in them , if i click on a button in the Sub Vi the Main Vi continues to run but if wont recognize any button press in it and Hangs as the Exit button is in Main Vi.
In the Main Vi there are Various button like Start , Stop , Up , Down , Configuration , Back and Exit ,
The Exit button will stop the Main Vi Execution and of all the Vi controlled by it , Start button is for Controlling the test running via Main Vi , Stop is for Stopping it , Up and Down for Incrementing and Decrementing the Values.
If the Back button is pressed on the Main Vi it should go back to previous panel and should close all other Vi’s called by it (here i am referring to the SubVi)
The Configuration button press should call the SubVi , which have its own Front Panel and buttons,
This SubVi is for configuring some parameters files and have buttons like New , Save , Save As , Delete and Back.
The Back buttons simply closes the SubVi or Abort the SubVi’s execution.
In my main Vi there is a While Loop having Event Case for handling the event
For calling the subvi i am not using this event case so i have created another while loop in the Main Vi , and connecting the Configuration button press to the True Case of the Case Structure and calling my SubVi dynamically inside the True Case , the New , Save , Back etc. Buttons work fine in the Sub Vi , but the Buttons on the Main Vi wont respond (Stop , Up , Down etc.) and even after coming back to Main Vi by pressing the Back button on Sub Vi , i am unable to control the events on the Main Vi via Stop , Up , Down and Exit buttons.
Can anyone help me in this so both the Main and Sub Vi run simultaneously with both able to handle there event case in parallel.
08-17-2015 01:34 AM
Hi Amitjoshi,
what you describe sounds like you could do it easiest with Dynamic Events: Create and register the events at the beginning of main, connect the dynamic ID to the dynamic event terminal in main and the Event Refnum to the sub VI. In the SubVI you generate a dynamic event, when you press a button, thus triggering the dynamic event in the Main. You can either create several dynamic events to handle different cases or just one and pass information about which button was pressed to the Main VI.
I've attached a short example for this.
08-17-2015 02:15 AM
First of all it would be helpful if you can provide us a somewhat simplified version of your LabView code to understand your problem better.
As far as I understood your descriptions you want to open a second front panel (besides your main front panel) when pressing on the configuration button. You also want your main VI front panel operational while your sub VI front panel is open.
I guess you have changed the window behaviour of your sub VI to "floating" in VI properties / "window appearance". So you don't want a modal dialog? Do you really need the configuration dialog to be non modal, because a modal dialog would be simpler?
Next, you are trying to handle the button events of your sub VI in a second event structure of your main VI, which is bad design in my opinion. Why don't you create an event structure in your sub VI and put all your configuration dialog related code there? This will make the main VI block diagram cleaner. If you need access to main VI front panel objects pass them as references to the sub VI.
As an alternative to dynamically calling the sub VI in parallel you can also use a separate while loop with a notifier waiting for a notification which you fire in the configuration button event. The notifier while loop will then call the sub VI and wait there until the subVI is closed.
08-17-2015 06:09 AM
Hello Peter and zaphod_b , thanks for the useful inputs , i am not very expert in Labview so still struggling with the inputs Peter has provided,
and zaphod_b - i feel that i was not very clear in explaining my last 3 lines of the query clearly ,
i am using a separate event sructure for the SubVi too ,
and for calling the SubVi from the MainVi , instead of using the Event case structure of MainVi i am wiring the Configuration button to the True case of a case structure kept inside a separate while loop (i already have a while loop in main Vi which hold the Event Structure of MainVi) and calling the SubVi inside this case Sturcture Dynamically .
The Only event when the Mainvi will be passing the information to the SubVi is when the Back or Exit Button of the Main Vi is Pressed.
If someone can share a Vi or post a screenshot with not all but few buttons for doing this it will help me understand and implement it faster.
08-17-2015 06:17 AM
Hello Peter and zaphod_b , thanks for the useful inputs , i am not very expert in Labview so still struggling with the inputs Peter has provided,
and zaphod_b - i feel that i was not very clear in explaining my last 3 lines of the query clearly ,
i am using a separate event sructure for the SubVi too ,
and for calling the SubVi from the MainVi , instead of using the Event case structure of MainVi i am wiring the Configuration button to the True case of a case structure kept inside a separate while loop (i already have a while loop in main Vi which hold the Event Structure of MainVi) and calling the SubVi inside this case Sturcture Dynamically .
The Only event when the Mainvi will be passing the information to the SubVi is when the Back or Exit Button of the Main Vi is Pressed.
and thanks zaphod_b for telling some new Keywords (Modal and Non Modal) , ya i want it to be Floating , so should be able to access any of them whenever required
If someone can share a Vi or post a screenshot with not all but few buttons for doing this it will help me understand and implement it faster.
08-17-2015 06:20 AM
Why don't you share your stripped down code at first? This would be quicker as if one of us try to guess what you really want and provide a VI for that. Just delete everything from your VI which is not needed to show your problem and give it to us ...
08-17-2015 06:21 AM
What exactly about my example are you struggling with? It should demonstrate the mechanics of remotely triggering dynamic events, does it not? You just have to pass the right event reference to the right event structure (which we could call a listener) when you launch everything and then the events can communicate with each other. To my example you would need to add another event which you register in the main VI and to which you pass the event registration refnum. (It's just the other way round from what is in my example...)