01-23-2013 10:24 AM
Hi guys!
Well, I'm in a little trouble.
I need to make an application with some GPS tools. Split data into indicators, generate coordinates (in google maps format), and so it goes.
One of the systems functions is the calculation of coordinates oscillation. The formula should be: latitude 1 - latitude 2 = latitude oscillation AND longitude 1 - longitude 2 = longitude oscillation.
Since I'm using two values, I thought: "Oh, if I log those data into a file, I just retrieve them and do all the math part." Yes, that idea is suitable for my needs (even if it's not the best, it solved part of my problem).
BUT, I can't see a way to write the current loop value and erase the old results.
For example, let's assume loop 1 gave me coordinates 1.00000 and 2.00000 and loop 2 gave me coordinates 3.00000 and 4.00000. Right?
My log file would be similar to: 1.00000,2.00000;3.00000,4.00000;
Well, that works. However, let's look forward to loop 3: coordinates 5.00000,6.00000.
If the program logs it, I'd get the string: 1.00000,2.00000;5.00000,6.00000; when I actually needed 3.00000,4.00000;5.00000,6.00000;.
Because of this, when I apply oscillation calculation, it will always take the most recent value and do all calculation with the first result (from loop 1).
Well, I wonder that there's a way to append new data to a file and replace the oldest values, with simple code. If someone knows how, please reply here!
Considerations:
1) I'd like to do it as simple as possible. My code is kind of big, and it's not suitable to insert structures or library right now.
2) Maybe the explanation isn't too simple as it's for me. I really couldn't find a better way to tell what I need.
3) If someone has any doubts about my doubts, please just comment and I'll try to be the more specific as possible.
Thanks in advance!!
Solved! Go to Solution.
01-23-2013 10:31 AM
Read everything in. Delete what you don't want. Write back the data you do want.
There isn't any other easy way.
01-23-2013 10:36 AM
Hello, thanks for answering!
That's a good idea, even if I see that I'd have to do some adjustments in my code.
I tell the result later.
Thank you
01-23-2013 10:46 AM
A really simple alternative would be to just keep appending the data in the file. When you do your comparison, you just look at the last 2 samples.
01-23-2013 11:34 AM
I guess my question is why write it to a file just to delete it.
If you pass an array of points from one iteration to the next you will not have to take the extra time to open the file, read the file, delete the old data, write the new data, save the file and then close the file. It would be just about the same thing, but without having to go to the hard drive.
Just a thought.
01-23-2013 12:35 PM
Hello Bryan,
Yes, that's a good idea.
At first time, I realized that would be much more simple to write and read data, even if they're temporally.
I'll try to make that. Thanks for it!!
01-23-2013 12:38 PM
@crossrulz wrote:
A really simple alternative would be to just keep appending the data in the file. When you do your comparison, you just look at the last 2 samples.
Hello Crossrulz!
Sorry, but I don't think I get your solution. You mean: log all data and then just read the last 2?
If is that what you meant, I don't remember any function on LabVIEW that reads last 2 samples without code size and complexity increasing.
Thanks for the answer!