09-19-2011 01:23 PM
Building on the previous post, I have created a text File I/O object and implemented the read functionality. Included is a small read test which exercises just about everything. This is definitely a work–in–progress, so any and all feedback would be appreciated.
The UML diagram has changed a bit, since I had some interdependencies on the Location object I had to reconcile. I also split files into pointer–based (e.g. binary or text) and hierarchy–based (e.g. TDMS, XML, or HDF5). Pointer–based files will use the Location object as a convenience, while hierarchy–based files will use it as the primary means of access. Implementing it in both will be critical to getting them to inter–operate. However, I have not yet implemented it for text. I will implement it, since it will be highly useful when I take text to the next level — spreadsheet files and LVM.
The file read is buffered, in hopes of speeding multiple accesses to the same file. This is based on benchmarks I did many years ago. I have not yet benchmarked it in a current version of LabVIEW. The primary use case will be repetitively fetching successive lines from a file, such as one would do accessing a spreadsheet type text file.
Searching for tokens and getting lines is supported. I have not tested this code very much, so there could be all sorts of bugs. Let me know what you think. I have already received the following feedback:
I realized as I was writing this that the basic algorithms also work quite well for binary files, since that is essentially what a text file is. So, implementation of a generic binary reader would not be too tough. The architecture would also work for almost any sort of streaming data access, such as networks or loop–to–loop communication.
02-08-2012 08:07 AM
Hi AQ,
Did you get any further with this side-project? (Is this the latest update?)
The zip you have attached to this post does not have the text File I/O object you talk about in this post.
I am in the process of rolling something similar (but significantly cut down feature set), I want to have a file class that can handle two (for now) different binary data formats.
02-09-2012 09:02 AM
You can find the latest update here, but it is still not complete, and it is currently undergoing a major rearchitecture, all while we are trying to get betas of our software out the door.
In short, due to the possibility of simultaneous access to a file, the state information needed to be in some sort of global, protected database. I could have used named single element queues (name being the filename) but after many conversations with a lot of folks here at National Instruments, I opted for a more elegant and expandable architecture, which I am in the midst of implementing.
I changed to a daemon-based model. There will be a master file broker to handle file open requests, and a specific file broker to handle I/O for each open file. The use of the file brokers ensures serialization of commands to any particular file (from any one process) and allows dynamic loading and unloading of file I/O code as needed. You can think of the file broker as a free-running action engine. I considered using the Actor Framework, but its use would have resulted in an extra copy of data at each save and read, and effeciency is paramount in file I/O.
If you subscribe to this thread, you will get notification when I post new code. Things are quieting to a dull roar, so it should not be too far off. Thank you for your interest.