LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Statechart passing data

            I would like to have a little more information about how data is getting passed with the StateCharts.  I know that under LabVIEW pass by value or pass by reference is controlled by the compiler but I was wondering with the StateChart how inputs and outputs are passed.  

            The reason that I ask is because I have an application where I am receiving a lot of data from 2 loops and I would like to place this vi into the StateChart format.  However, the true reason for the statechart is not the data acquisition part but the user interface to the data and various screens shown to the user.  Since the data from the 2 loops is being used to display data to the user all data from the 2 loops needs to be passed back to the user interface loop for display.

            While a little cumbersome to put the data in the inputs and output .ctl files, if the Inputs and Outputs are pass by reference (i.e. not copied over each time) I would think this would be a better solution than using a global variable or shared variable.  Currently, to handle the data I am using the in place element structure such that the data is not being copied.

0 Kudos
Message 1 of 7
(3,168 Views)
Why don't you just use queues for this? Have a look at the producer/consumer architecture. The data in the two DAQ loops can be written in a queue (or separate queues) and the statechart that you design in the third loop as user interface can read from this queue and display the information to the user.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 7
(3,159 Views)
Thank you, a queue was the other idea that I had but not knowing how the queues are passed I was unsure of how to proceed. If I remember right, LabVIEW is very generous with creating copies of data to prevent issues with the sharing of data. I just finished with a project that ran into this issue when I was processing a large file. With the queue how do you ensure that LabVIEW is not copying the queue over also? After posting the message I found http://zone.ni.com/devzone/cda/tut/p/id/7812 which covers transferring data into statecharts and is good. However, some of the methods only work with controls and not indicators (i.e. the references method).
0 Kudos
Message 3 of 7
(3,154 Views)
Have a look at the Synchronization sub section at the link that you have posted. You are not copying the queue over but rather pulling data values out of that repository.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 4 of 7
(3,139 Views)

Data is passed in to/out of the statechart in the same way data is passed in to/out of a subVI (by value). You can place the type of data you want to provide to the statechart in the input/output control typedefs of the statechart. If your passing in/out and use of the data in the statechart is done right, no data copies will be made (as is the case with a subVI).

 

Alternatively, you can also use techniques like the single-element queue to get by-reference behavior if that is what you want.

 

Hope this helps.

 

- Nick

 

0 Kudos
Message 5 of 7
(3,128 Views)

Nick does this mean that all data that is to be passed or altered between states in the stechart have to be included in these 2 controls' definitions?  In other words if I have a 4 state chart and a single unique variable that is only used by states 2 and 3, I need to have it defined in these controls which serve as teh interface to the entire statechart.....

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

Hi id,

 

This thread is fairly old, if you post an issue to a new thread, you're more likely to get traffic.

 

Regards,

Joel I.
Applications Engineer
National Instruments
0 Kudos
Message 7 of 7
(2,695 Views)