02-09-2019 06:58 AM
Hey,
imagine you have a data-stream incoming from somewhere. You can interpret it as ASCII signs. Let's say you want to work with some signs they are coming in, but not of all them. E.g. let's say I have to find certain signs and write them in a file.
But my problem is that the data stream won't stop and is just giving me data. So I need a buffer, where I store the rest of the data, which I haven't touched yet. But how can I do this, when always data is coming in?
Do you have any tips for that?
-tommy
02-09-2019 07:37 AM
Look up Producer/Consumer Design Pattern.
LabVIEW is based on the idea of Data Flow -- a "Structure" (a loop, a VI, a Case Statement) doesn't start until all of its inputs have data, and none of its outputs have data until the Structure finishes (at which point, data are present on all of the outputs). What this means is that you can have multiple structures (loops, VIs, etc.) running "simultaneously" (or as best at the computer can do so).
In Producer/Consumer, you have one loop "Producing" data (say, reading from a data stream incoming from somewhere and saving the data someplace), and another, independent, loop running at its own speed and processing, or "Consuming" any data "saved someplace". A common method for handling the intermediate data store is a Queue, which you can think of as a "flexible storage location, with one routine, "Enqueue", for adding data at one end and another routine, "Dequeue", for seeing if data are present and giving you the oldest remaining member of the Queue. Here is an NI White Paper on this topic.
Bob Schor
02-10-2019 04:58 AM
Thanks for the tip.
Is it somehow possible to create a 'virtual' data flow with LabVIEW for just a simulation and to see if my Producer/Consumer Design Pattern is even working?
02-10-2019 06:41 AM
@tommy_shelby wrote:
Is it somehow possible to create a 'virtual' data flow with LabVIEW for just a simulation and to see if my Producer/Consumer Design Pattern is even working?
I don't know of anything to virtually simulate a serial port other than you making your own simulator (ramp pattern, sine wave, random number, etc) to replace the VISA calls.
02-10-2019 06:43 AM
Hi tommy,
s it somehow possible to create a 'virtual' data flow with LabVIEW for just a simulation and to see if my Producer/Consumer Design Pattern is even working?
Sure!
02-10-2019 10:06 AM
@tommy_shelby wrote:
imagine you have a data-stream incoming from somewhere. You can interpret it as ASCII signs. Let's say you want to work with some signs they are coming in, but not of all them. E.g. let's say I have to find certain signs and write them in a file.
Tommy,
You asked for a "virtual data stream". Here's one way to do that:
Bob Schor