02-28-2012 06:50 AM
Hi everyone,
I'm busy with an application where I want to load a large block of data into a graphic.
The file that I want to load into the graph is a .txt-file.
I did put one line of data into the .txt-file and copied that, just to have a lot of data into the file.
The problem is, that when the file is above approximately 10MB and up, the application is having a lot of effort to do this without problems.
Most of the time the VI will hang and nothing is possible anymore.
In the attachments you can see how the file is build up.
I also attached the VI with Sub-VI's.
Another question, if I zoom in on the graph, is it possible to see the zoom factor?
Because maybe it is possible to leave some data out of the file.
I am logging data for every 5 minutes.
Maybe it is possible to, when I didn't zoom in, one sample per hour is shown in the graphic.
And when zooming in, there will be shown more points of the graph.
But then I have to know if I can read out the zoom factor.
Regards,
Kenny
02-28-2012 07:57 AM - edited 02-28-2012 07:58 AM
I honestly don't understand what you are trying to do. Why are you loading a text file into a graphic? That makes no sense to me. What is in this text file? I saw the sample file you provided, but I don't understand how I'm supposed to interpret it.
You code has a few issues (such as NEVER HARDCODING PATHS), but I'd rather try to undestand the concept of what you are doing before commenting on the implementation.
02-28-2012 08:01 AM
You will probably have to change your file storage strategy. Take a look at this article:
http://zone.ni.com/devzone/cda/tut/p/id/3625
Is it possible to reduce the amount of data in each file? For example, if you know the delta - t, you could leave out the timestamp. Instead of one large file, could you use several smaller files? You also need to be mindful of the arrays you are using and how much data is staying in memory.
02-28-2012 08:31 AM
Dear Smercurio_fc,
I have a sampler that is writing every 5 minutes some measured data into a txt file.
The variable names of the values that were sampled are shown on top of the txt file.
The reason that these are shown, is that they can be selected (one or more) in the "#plots" box which is also shown.
After that, the variables are shown after each other, with a tab between them, and under them the sampled values.
If you want to see it good, you can copy the tx file into excel, than it's easier to read and understanding it.
The reason why I'm using a hardcoding path is that this is a test VI.
If it's ready and working, I will build it into my main VI.
I hope it is a little bit clearer for you know.
Regards,
Kenny
02-28-2012 11:41 AM
OK, so when you said "graphic" you meant graph. Because a graphic is a picture, so that's why I was confused.
So the file you are trying to read is being updated continuously by some other program, which I assume you cannot change. In that case, you want to be able to show all the data on the graph. This means you basically have two issues. The first is to parse an ever increasing file, and the second is dealing with ever increasing data in your graph. Here's the things I can tell you:
I've attached modifications of the two core subVIs as well as the top-level VI to show an improved performance.See if they make sense. I made a small artificial change to the timestamps since the timestamps in your sample data are all the same. I do not know if this is a real file, or whether you just copied the same line over and over again (I am guessing the latter).
However, this does not solve the main problem, as that requires a lot more work. What I would do is to keep track of how much of the file you've read. Thus, in the loop, do not keep reading the whole file. Only read the additional lines. This way, you have a lot less data to parse. As for the graph data, I'd suggest pre-allocating a large buffer for the data and simply using Replace Array Subset to fill in the buffer as you read lines from the datafile. If you need more, then allocate a larger buffer and use that instead, throwing away the previous buffer.
Good luck.