11-29-2017 06:41 AM - edited 11-29-2017 06:47 AM
Hi, there!
Here is the test program where I write 2d arrays (3 columns and 10 rows) to binary file in loop, appending new arrays to end of file. It seems nice - file is growing wile new arrays append.
The problem is that I can't read the whole data from file. I expect to have an array of 3 columns and rows multiple by 10. But all I have is just first 10 rows - first 2d array. Though the size of read file is rather big.
Is there some kind of end-of-file mark after file is closed and therefore I can't read the whole block?
(SubVi is creating data for arrays)
Solved! Go to Solution.
11-29-2017 07:44 AM
Open up context help for both the Read and Write Binary Files and look at all of the inputs.
In your Read, you do not have a constant wired to the "Count" input It defaults to 1.
Also complicating things is that you are writing a 2-D array, and that you have Prepend Array or String Size which is needed so you know how the dimensions of each 2D array as you write it.
Wire a -1 to the count on reading. You'll wind up with a 1-D array of clusters of 2-D arrays. Go through the that array in a loop building up a new array from the element in that cluster.
11-30-2017 07:20 AM
Thanks! That helped alot!
Didn't know about array cluster.
Here is working VI:
(No file exist checking, though)
11-30-2017 07:56 AM
Excellent. That is good to hear. It looks like you implemented what I was trying to describe.
If I could make two suggestions.
1. I prefer using a shift register rather than a local variable to get the existing data and append to it. You'd need a shift register on the inner For Loop and Outer while loop, and make sure that the wire is wired through all cases of the vent structure. One other alternative if you don't need that data elsewhere is to use a feedback node inside of that For Loop. The advantage is that LabVIEW doesn't have to make an extra copy of what could be a large amount of data because of the local variable.
2. I'd move the Number to Decimal string and both indicators outside of the For Loop. It will make the process go faster. No need to update the indicators on every grab of an element from the cluster or doing the number to string conversion repeatedly is unnecessary Just allow that to happen once the For Loop ends.
12-01-2017 03:41 AM
Thanks for advices.
The first one is yet to be tried.
But the second one is kinda tried already. I think, I have lack of knowledge about these for loops, cause I wanted the data to be updated after the loop ends, but the wire that is coming out of loop is not the proper type for 2d array.
Yet, you are right, it is not the way it should be done. Yhough working.
12-02-2017 05:04 PM - edited 12-02-2017 05:06 PM
@Prain wrote:
Thanks for advices.
The first one is yet to be tried.
But the second one is kinda tried already. I think, I have lack of knowledge about these for loops, cause I wanted the data to be updated after the loop ends, but the wire that is coming out of loop is not the proper type for 2d array.
Yet, you are right, it is not the way it should be done. Yhough working.
Coming out of a For Loop, it probably turned on auto-indexing on the tunnel adding a dimension to the array. Just right click on the tunnel and set it to output "last value".
One other thing you could do, I think your LV version 15 has this feature. Get rid of the shift register or feedback node, or local variable. Make the output tunnel concatenating. Unless your array is oriented the wrong way, that should work.
12-06-2017 07:06 AM
Wow! Thanks! That looks much better now.
I made it without shift registers by setting tunnel mode to concatenating and moved array indicators out of forloop.
So many ways to do the same thing.
Now to the main point: to make the same in xml format and finally try out TDM storage. But that is another issue.