LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

what happens when a type defed cluster has an element of its data changed by two different vi's?

Solved!
Go to solution

Let's say I like the use of a cluster/typedef to use as a mechanism for gathering together all the variables I want to deal with in a vi.  Now I create a second vi...and also use the tyepdef cluster to create a wire with the same variables in it.  Are the instances of the variables in vi1 seperate from the instances in vi2....if so, would there be some mechanism for passing the values back and forth between the two vi's effeciently...would that be a (gag...) global with scanning on each end?

 

Hummer1

 

0 Kudos
Message 1 of 7
(2,939 Views)

"Ask and you will recieve."

 

I have to agree with the post that Nathnd will post shortly were he will write " or use a functional global variable (also sometimes referred to as an Action Engine, "

 

See here for myNugget on Action Engines.

 

Ben

Message Edited by Ben on 02-10-2010 10:04 AM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 7
(2,931 Views)
You might be misunderstanding a type definition: it defines only the type of the data, not the contents.  Multiple wires carrying the same type of data do not necessarily carry the same values.  If your two VIs need access to the same data, then wire one of them directly to the other, or use a functional global variable (also sometimes referred to as an Action Engine, search for that term on this forum and you'll find lots of information) to store the data.
Message 3 of 7
(2,927 Views)
Solution
Accepted by Hummer1

A typedef just defines a control as being a certain defined "type". It's basic structure can only be really changed with the control editor, but when it is changed there the changes are propogated to where ever the control is used. Now, having created this typedef'd control you can use it to pass data between vi's in a few ways. The least popular in the current thinking is the global. The reasons have been talked to death in this forum. Another method would be using a "functional global"a.k.a. "LabVIEW 2 style global", which has the advange that it is locked while any vi is accessing it. Yet another method would be to write to a queue in the one vi, and read from it in the other. There is a new "global", which has its uses, called the "shared variable" These all have advantages and disadvantages. Search on the highlighted terms to learn more.

 

 

Ben, how did you know what nathand was going to write, is he sitting near you?

Message Edited by LV_Pro on 02-10-2010 11:08 AM
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 4 of 7
(2,918 Views)

Thanks...

 

(Ben knows everything...he was in the Navy.)

 

Would a good strategy be to use the type def to make sure that all the applications had the same variable types available to them, and then use one of the shared/or other common access methods to get to them when needed?

 

Hummer1

0 Kudos
Message 5 of 7
(2,885 Views)

I attempted the shared Queue approach and had a bit of a problem.  I will have to build a small sample set of vi's to investigate as the problem may (probably was) operator error.  Because of the confusion (mine or LV's) I'm going to stay away from that for the moment.

 

Hummer1

0 Kudos
Message 6 of 7
(2,882 Views)

Hummer1 wrote:

Thanks...

 

(Ben knows everything...he was in the Navy.)

 

Would a good strategy be to use the type def to make sure that all the applications had the same variable types available to them, and then use one of the shared/or other common access methods to get to them when needed?

 

Hummer1


Yes, that is exactly what typdefs are used for. They are the defintion of a piece of shared data. If everything accessing specific instances of teh data use the typedef if the definition of teh data type changes all users will get the new definition.



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
Message 7 of 7
(2,878 Views)