01-25-2006 08:55 AM
01-26-2006 01:46 PM
Good afternoon Larry,
Thanks for posting!
The Datalog file support in LabVIEW has changed, but the underlying
principles of the technology remains the same.
Converting to the new format should just involve converting a few
Before we address the concerns with the errors, let’s first make sure that the code has been properly converted.
To convert your VI to the new format:
1) Replace the Open File VI from LabVIEW 7 with an “Open/Create/Replace Datalog” VI in LabVIEW 8. Keep your type constant or control wired to the “Datalog Type” input.
2) Replace
any “Write File”
3) Replace
any “Seek”
4) Replace any Reading VIs with the corresponding “Read Datalog” VI.
I suspect that if you are receiving errors saying that the end of file has been encountered it is a result of a bad input to the “set Datalog position” VI. I attached a basic example of writing a Datalog file in LabVIEW 8, and reading the results. The rest of the functions in the new Datalog palette should be pretty straightforward.
Does this help? I would be more than happy to answer any other questions on this if you need any additional clarification, or if this response does not address your question.
01-27-2006 09:11 AM
Travis,
Thanks for replying! The problem has not been with the use of the new LabVIEW 8 datalog file vi's per se. My problem is with trying to read version 7.1 datalog files containing variable-length records, for example, clusters containing variable-length arrays. I've attached an example to illustrate the problem.
Create LV71 Datalog File.vi is a LabVIEW 7.1 vi that creates a datalog file containing records based on the typedef Record Definitiion.ctl.
LV71 Datalog File.dat is one such file created by the above vi.
Read LV71 Datalog File in LV8.vi is a LabVIEW 8.0 vi that uses the new datalog vi's to read a datalog file containing records of type Record Definition.ctl. When this vi tries to open LV71 Datalog File.dat, error 71 (File data type conflict) is generated.
If Record Definition.ctl is a simpler (fixed length?) data type, records written by LV7.1 are read fine by LV8 without generating an error.
So my question again is: "How can I convert my LabVIEW 7.1 datalog files containing variable-length records into files that are compatible with LabVIEW 8?" My files are large databases that must be ported with the next release of the client application.
Thanks!
Larry
01-27-2006 05:02 PM
Hello Larry,
This is indeed an interesting problem -- sorry I believe that I misunderstood
your question earlier. However, I still can not reproduce the behavior
you described. I ran the LabVIEW 7.1 write Datalog file and created a new
Datalog file, and used the reader in LabVIEW 8 without any problems!!
When I ran the reader on the dat file you sent sure enough -- CRASH. The
only difference I can see here is that I am running LabVIEW version 7.1.1f2
which is a patch for LabVIEW 7. I could not find specific record of this
being something that was fixed, but its worth the time to upgrade!
Additionally, I'll attach the data file that I generated with LabVIEW 7.1.1f2
-- please reaname to a .dat file and try to open it with your 8 reader and let me know if you get the
error.
Have a great weekend!
http://digital.ni.com/softlib.nsf/websearch/6C5F342A4AF4EF8986256F5400693C3B?opendocument&node=132070_US
http://digital.ni.com/softlib.nsf/websearch/E0768D56ECF0BDB9862570BB005C4CD9?opendocument&node=132070_US
01-31-2006 10:38 AM
Travis,
Thanks for the follow-up. It was very helpful as you'll see below.
I had no trouble opening your attached datalog file, so I tried to reproduce the error on my side again. I created five LV7.1 datalog files in the same manner as before, and this time had no trouble opening them up in LV8. They were all between 2578 - 2638 bytes in size - similar to your file of 2628 bytes. (Some variability expected due to use of random number generator.) I then discovered that I had two files named LV71 Datalog File.dat on my hard drive. The correct version could be read just fine, but I had mistakenly performed my read tests using the wrong version which had been created with a different record structure. This explains the type conflict error produced with the previously attached datalog file. My apologies for making this blunder.
So I'm back looking at my larger application which still generates errors intermittently. I'm seeing that even when re-reading the same record over and over, errors are inconsistent. Sometimes one of the two Read Datalog.vi instances generates an error (either 4=eof encountered or 116=unflatten or byte stream read operation failed due to corrupt, unexpected, or truncated data) and sometimes they don't. My plan is to try to distill a test program down to the essentials that still causes this behavior.
Larry
01-31-2006 01:34 PM
Hello Larry,
I hope some of these help – please let me know if further investigation sheds any more light on the situation!
01-31-2006 02:27 PM
Travis,
You've outlined three excellent approaches. I've already completed the first. I extracted the essential features of my larger application and put them into a new version of the test vi called Read LV71 Datalog File in LV8.vi (included in attached zip file). Surely the non-standard approach I've taken to opening the file is the culprit that summons a bug of some sort. When I wrote several general-purpose datalog file routines in the past (e.g. Open Datalog File with Timeout), I had to use a variant record type terminal for defining the datalog type. Then, to simplify subsequent file operations, I would typecast the returned refnum in the calling vi using a file refnum constant containing the same typedef record structure that had been wired to the variant record type terminal. This worked reliably in version 7.1, but apparently has issues in version 8.0.
I have included two datalog files originally created by my larger LV7.1 application in the zip file together with the test vi so you can see the behavior for yourself. I noticed that if I DON'T convert the record type to a variant before wiring it to Open/Create/Replace Datalog.vi, I receive error 71.
Regarding your suggestion #2, I have not been able to discern any patterns beyond the fact that when a file opens "properly", records can be read indefinitely without an error. When a file opens "incorrectly", an error occurs almost always upon the very first attempted read operation.
Your third suggestion is a good one for exploring the problem further and I will likely try that next. Upon successfully opening a database file "properly", I should be able to read each record and then write the records to a new file with a more conventional use of the datalog file vi's (i.e. without the use of variant record types and typecasting of file refnums). This would render my general purpose vi's that rely on variant record types obsolete, however, so other workarounds would certainly be of interest.
Thanks for your continued attention and helpful advice.
02-01-2006 08:07 AM
Hello Larry,
First, let me say that I cannot open the attached example
because about a dozen typedef controls are missing from the control attached so
I was unable to run the VI. Second, I am
pretty confused as to why you are typecasting the datalog file refrence from
the create datalog file
Keep me posted (so to speak)!
02-01-2006 01:12 PM
02-02-2006 08:51 AM
Hello Larry,
First, I believe that there are still missing controls that prevent me from running this example (see the attached screenshot). Additionally, I believe that there might be some sort of corruption with this VI because any time I attempt to make a copy of the “Record Read From File” indicator I get a LabVIEW crash (in fact this happens any time I try to copy anything with the record type in it – the constant, the indicator, or the control)! This might be related to the custom controls being absent, but I’m not exactly too sure on that.
I believe that while complex, what you are trying to do should work. I am not convinced however that there’s not an easier way. First, to address the open datalog with timeout – you pass in the variant representation of the cluster control. Since the datalog file is written with cluster-records and not variants I do not see how you can do anything other than open the file reliably (but your program seems to be able to ascertain the number of records from the file). If your number of records in your datalog file is somehow incorrect it could throw off the rest of the program – interestingly enough the number of records is computed using the file size in an equation with the size of the record. If the record type wired to your “open” file is different than the record of the file (even slightly) it could compute erroneous results. It’s a little early (in the morning) for me to say for certain, but that is one possibility. Another question about this VI, assuming that we would want to move the size detection outside of this VI, is why create a variant with a real type to begin with? If all the VI is going to do is open the file depending on its availability, and the file’s refnum will be cast to a datalog file type of your choosing I think it’s a possibility that we wouldn’t need to send anything in but an empty variant constant. I realize that this shouldn’t alter the operation of the program, but it will speed things up and reduce some complexity, as creating/copying variants is no quick task.
Finally, I would like to note that it appears that your control is made up of many smaller custom controls which may have been changed over time. You have a constant of your type which is used with the typecast to declare to your program what type of datalog file is present. I’m sure you have tested this, but you want to make EXTRA sure that everything in the constant matches exactly what LabVIEW expects in the file, and the indicator on your front panel.