07-14-2014 10:11 AM
Dave_brandt
That is very time intensive, not condusive being used in a program loop, and since this is a sub_vi, storing those values can be done in memory.
07-14-2014 10:17 AM
The problem can be solved by passing a reference to the VI for that particular indicator and then only updating the value for the indicator class of that reference when applicable.
07-14-2014 11:08 AM
The shift registers and a wire is the fastest way to pass data in/out of a subvi. The only faster way would be to write the code in the main vi. The sub vi while loop only runs once because of the constant true on the stop if true. If you are going to use references the dynamic event structure would be a good choice. It would run in a different loop just waiting for your event. This could be a a subvi outside your main loop. But there are many ways to code in Labview. Choose what you like the best.
07-14-2014 11:58 AM
@eximo wrote:
The problem can be solved by passing a reference to the VI for that particular indicator and then only updating the value for the indicator class of that reference when applicable.
Unfortunately, this "solution" would likely break in a standalone executable because it 's referring to a front panel object and LV won't retain the front panel of a subVI in most situations.
Mike...
07-14-2014 12:07 PM
mikeporter wrote:
@eximo wrote:
The problem can be solved by passing a reference to the VI for that particular indicator and then only updating the value for the indicator class of that reference when applicable.
Unfortunately, this "solution" would likely break in a standalone executable because it 's referring to a front panel object and LV won't retain the front panel of a subVI in most situations.
Mike...
Any static references to a front panel element should force the front panel to be in the executable. But having a property node in the subVI will also cause that VI's front panel to be in the executable. That is a potentially large amount of memory that would be added that likely isn't needed at all. And property nodes are a killer to execution time.
I really wish an example VI was given so that we could see exactly what the OP was seeing and suggest something better than passing around references.
07-14-2014 12:31 PM
I know this example would not work in a working vi or executable. I think the fields reseting is the issue of not understanding how a subvi pass out the data when the subvi is executed. Any control indicator value inside an un-executed case structure in the subvi will pass the default value for that data type. This is just to show techniques of how to do something, just like the NI examples usually can not be put directly into your code. I thought we are suppose to share Ideas here and not provide code. If you teach a man to fish and feed him for a lifetime. Sorry for not being clear in my earlier post that my solution would not completely work. It was just trying to show how to pass multiple control indicators out of a subvi using shift registers.
07-14-2014 01:00 PM
@Dave_Brandt wrote:
I know this example would not work in a working vi or executable. I think the fields reseting is the issue of not understanding how a subvi pass out the data when the subvi is executed. Any control indicator value inside an un-executed case structure in the subvi will pass the default value for that data type. This is just to show techniques of how to do something, just like the NI examples usually can not be put directly into your code. I thought we are suppose to share Ideas here and not provide code. If you teach a man to fish and feed him for a lifetime. Sorry for not being clear in my earlier post that my solution would not completely work. It was just trying to show how to pass multiple control indicators out of a subvi using shift registers.
I think you misunderstood. We were commenting that the passing around of the control reference was a bad idea. Using shift registers is likely the better way to go. But it is really hard to say without seeing what the OP actually had.
Simple examples will show somebody a lot more than just talking about something. So I encourage examples that just show the concept. Don't do their project, but show how to get over a hump. They will have to put the code in their project.
07-14-2014 01:17 PM - edited 07-14-2014 01:44 PM
CrossRulz,
So I had thought that references were akin to pointers in C. Pointers are generally faster since they access the location and don't require a copy in memory. Why would references not be faster?
I agree a shift register could be used to accomplish this task, but they are MESSY! They span the entire VI, (although a feedback node could be used to reduce the number of wires running across the screen.
-JW
07-14-2014 01:27 PM
Here is an example subvi, I can create the main if necessary
07-14-2014 01:57 PM - edited 07-14-2014 01:57 PM
eximo wrote:
So I had thought that references were akin to pointers in C. Pointers are generally faster since they access the location and don't require a copy in memory. Why would references not be faster?
And that's where a lot of people go wrong. It is not a pointer. It is a reference to a control object. And when you read or write to a property of a control object, it forces a thread swap to the User Interface. That alone is kind of expensive time-wise. But it also forces the front panel(s) to be updated. That will be an really big hit to your performance.
From your example, I would use a feedback node or shift register. They are quite clean (in done correctly) and very efficient.