LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Network streams to pass data into a subVI

Solved!
Go to solution

Hello All,

 

I'm using network streams to transfer some data to my PC from cDAQ 9132 with LabVIEW 2017. The data is a 2D array of string. The data transfer keeps happening and once every 60 minutes, a subVI will be triggered and open in front panel. At that time, I don't want to view the data in my main VI and I want to view it in my subVI. What should be the best approach for this. I have tried using passing the network streamed data to a global variable and reading it in the subVI. But the VI is slowing down. and I'm not able to see the live data properly. Can anyone please suggest a better method than this.

 

 

Regards,

Rishi

9995071465

0 Kudos
Message 1 of 8
(3,274 Views)

Hi Rishi,

 

what exactly have your tried?

How does it "slow down"?

 

Mind to attach your VIs (or the whole project as a ZIP)?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(3,269 Views)

There are a few ways to stream data over the network. Network Streams is certainly a good one. Another is Network Shared Variables with the FIFO option turned on.

 

I assume you are transferring data from your cDAQ to the main VI on your host PC. Then every 60 minutes you open a subVI which should present the analysed data.

 

You could Network Stream the data to your mainVI, and store the data in the mainVI. Then launch the subVI and tell it the data you want it to present using the connector pane, very simple!. The subVI will not have access to the live data however, just the data that was available when the subVI launched. For live data, you will need to pass the new data from the mainVI to the subVI. I would normally use a queue for this sort of transfer. You will need to work out when you transfer data and how you want to buffer it in the subVI, but this is all straightforward with practice!

CLA - Kudos is how we show our appreciation for comments that helped us!
0 Kudos
Message 3 of 8
(3,253 Views)

Hi GerdW,

 

Sorry. I'm not allowed to share any part of the code online. My intention is once the program starts running, it will compare the start time logged with current time. If the difference reaches exactly 1 hr, then a subvi will pop up and the data which was streaming from cDAQ 9132 to my Host PC should be available in only my subvi not the main vi. The method I have used is, the data which is getting streamed is passed to a global variable and inside the subvi I'm again calling the global variable and passing the same data to display in a graph. I need to know if there's any other methods apart from this. Because, sometimes, the graph data doesn't seem to be instantaneous and the subvi slows down. ie, the graph data is getting stuck.

0 Kudos
Message 4 of 8
(3,247 Views)

Hi Max, 

 

Yes. but a small correction. I need to see the instantaneous data only. I'm not storing the data in my main VI. ie, the data streamed over the network is visible in a graph in a subVI.  Isn't the network shared variable a lossy one? I might lose the data if I use network shared variable. It's ok if i share single element, but I'm transferring a 2D array of string. It may have at least 500 elements.

0 Kudos
Message 5 of 8
(3,243 Views)

As I recall, Network Shared Variables were introduced about 10 years ago (about the time I started using LabVIEW seriously).  I spent considerable time trying to use them for purposes similar to those you describe, and essentially gave up, saying "Not yet ready for serious work".  About six years ago, I discovered Network Streams (I think around LabVIEW 2011 or 2012) and used them very successfully.  I also briefly re-introduced Network Shared Variables for some "incidental Status Monitoring", non-time-critical stuff, but again abandoned them as "not sufficiently reliable and stable".  Maybe things are better now, but I've found Network Streams to be much more reliable ...

 

Bob Schor

Message 6 of 8
(3,228 Views)
Solution
Accepted by topic author RishiDivakar93

I agree with Bob that I have had problems with NSVs in the past, mainly due to services stopping and then the NSV function falling over silently. With the FIFO option turned on, they are not lossy. And they are conceptually simpler to implement (in my opinion) than Network Streams that require connections to be made 'manually'.

 

That said, I would overwhelmingly favour Network Streams for this application.

 

Well, Rishi, the application sounds odd, you are streaming data continuously and forgetting it, but only after 60 minutes you want a subVI to pop up detailing the streamed data. It seems a bit convoluted, but ok, I'll run with it!

 

Set the Network Stream to send data from the cDAQ to the mainVI. At some point in time, create a queue on the mainVI and start a subVI, passing it the queue reference. Pass the data from the stream into a queue on the subVI. Dequeue the queue on the subVI and present the data.

 

Are you familiar with producer-consumer design? I would recommend this for handling the queues and messages between the subVI and the mainVI. Good luck.

 

PS it is perfectly reasonable to post example code, rather than your real code. Make a new project and implement only the bits of interest, then send us that project. We will still have no idea how your main code operates but can effectively help your problem.

CLA - Kudos is how we show our appreciation for comments that helped us!
0 Kudos
Message 7 of 8
(3,221 Views)

Hi Max,

 

 

I'm not forgetting the data in main VI. The data I'm getting in main VI, I'm already saving it in my PC csv files. However, when the subVI pops up, I don't need those data to be saved because the data I'm getting from cDAQ is being used for some other analysis purpose at that time. I have used Producer Consumer architecture now however, connecting the queue references to the consumer loop makes my code look a bit bigger. That's why I opted global variables method. Thank you so much for your comments. I will proceed with PC architecture.

0 Kudos
Message 8 of 8
(3,213 Views)