LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Copy/Paste Event Strucutre

Solved!
Go to solution

Hello everyone

 

I am working on a big VI and facing problems to run it on different screen resolutions. Too many controls, indicators, graphs, etc. If I let Labview resize the objects and font sizes everything gets messy. Because of that I decided to create multiple VI files, one for each screen resolution. Then, the first VI to run detects the actual screen resolution and loads the right VI for that screen.

 

Everything works like a charm but when I need to update something into my code (put a new SubVI to run, create a new event case into event structure, etc.), I have to do the SAME procedure multiple times, to update all the VIs with different screen resolutions.

 

After long thinking I came to the solution of remove all the booleans or indicators from the while loop, set the buttons as "Switch when released" and restore the button previous state programmatically. Since I never (or almost never) update any thing into Front Panel, I can do all the needed changes in one single resolution VI and after finish everything I can just copy the whole while loop and paste it into all the screen resolution files. After that I just have to connect one wire (for the References Clusters) and I am good to go. All the screen resolutions files will work identically.

 

The problem: when I copy the while loop and paste it into a new VI, all the event structures events (to handle the cases) are not kept. Then, I have to edit the events that will handle each case of the event structure and repeat the same procedure for all the screen resolutions files. Since is impossible to let Labview adjust objects and fonts size and distribution, I have to keep using multiple files.

 

If I solve the issue with the events that are not kept when I copy and paste the while loop, everything will be fine.

 

My code is really big, with several SubVIs and stuff, but the attached files show you the main idea of the problem that I have. Open Resolution 1.vi, copy the whole while loop and paste it into Resolution 2.vi. The primary idea was just to connect one wire and I would be good to go, but the events are not kept into event structure.

 

Thanks

 

Dan07

Download All
0 Kudos
Message 1 of 20
(4,062 Views)

Have you tried Save As ... and selected save a copy? That way you should keep all items and just be able to resize them afterwards.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 20
(4,048 Views)

Yamaeda

 

If I use "save as" it will really work. But, the front panel has a lot of controls and indicators and resize them is not a easy task. I did it once, for all the screen resolutions, but now I want to find a way to update the "coding" part of my code without having to change the "comestic" part every time. I was thinking about get the height and width as well as the XY position (pixels) of all objects on the screen and put all this data into a array of clusters. Then, each cluster would represent a screen resolution and as my code detects the current screen resolution, all the objects would be resized and moved as needed. I believe that this second plan will be the solution. But I still want to know how to copy and paste a while loop, from one VI to another, and keep the events that handle the event cases.

 

Thanks

 

Dan07

0 Kudos
Message 3 of 20
(4,043 Views)

Perhaps what you need to do instead of having multiple VI's is to create an intialization routine that sets the sizes and locations of all the controls on your front panel using their property nodes.

 

Then depending on which resolution you want to set, you write the appropriate set of values to those property nodes.  Having multiple VI's will lead to big version control issues no matter how hard you try to keep all of the code synchronized.

Message 4 of 20
(4,036 Views)

The proper way to have it is to separate the coding from the GUI.

Make a GUI vi and open a VI ref to the resolution VI of choice, then you can put values into all controls through the Invoke Node: Control Value -> Set. As long as all VIs use the same control and indicator names it works. If they use the same names as your coding vi you can extract the control names directly.

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 20
(3,991 Views)

Yamaeda

 

I understood what you said about separate GUI from code. This works great when I want to pass values to the controls but considering that the code will be in one single VI and I will have several GUI VIs, if i click a button (for example) into one of the GUI VIs, how do I use this event to trigger an event structure into the code VI? Then the code VI will run some calculations (for example) and send results back to GUI VI. Since into GUI VIs I will not have any code, how do I tell GUI VIs that to push LOAD button (for example) is the trigger for "Load: value change" event case into code VI?

 

Thanks

 

Dan07

0 Kudos
Message 6 of 20
(3,974 Views)

You can use user defined events and fire the appropriate event for the GUI VI you are using. Alternatively you can get the references to the controls you need for the GUI VI you are using and have your event structure use those to set/get values when necessary. The nice thing about this approach is that you can use a single event structure. The specific display GUI VI would be a very basic shell that only provides the display aspect of the GUI. Your workhorse VI would be the GUI processing engine. This is where all the logic for processing the user interface would be.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 20
(3,961 Views)

I haven't done this myself, but we do similar things in my current project. As Yedinak says, you can create (and rgister) user events in your Processing vi, which you send to your GUI (as a cluster, array or similar, i'd go for cluster since it allows naming). The GUI can then be really simple and stupid, the indicators are fed as mentioned in my previous post, and the button events in the GUI only fires the user events.

 

I'll whip up a simple framework.

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 20
(3,947 Views)

Not functioning VI, but it'll show you how the two VI's can collaborate.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 20
(3,935 Views)

Yamaeda

 

Could you save the VI for Labview 8.6?

 

Thanks

 

Dan07

0 Kudos
Message 10 of 20
(3,908 Views)