LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving Class Object to Binary with TypeDef Enum

Solved!
Go to solution

I'm curious if this is expected behavior. I'm trying to save a class object to a binary file. In the class private data, I have a type def enum. If the type def changes after the data has been written to disk, the data coming back out reverts to the default value of the enum.

 

I've been working under the assumption that "Labview automatically creates algorithms for changing data from old format to new format when you edit your private data" (quoted directly from the section on storing class objects to disk in the object oriented programming in labview course). It doesn't seem to hold true in this instance. I've attached an example that demonstrates. To reproduce:

 

1. Run "Write Binary.vi" and a binary file will be saved with the enum value set to Val3.

2. Run "Read Binary.vi". The results should be Val3 as expected.

3. Open "TypeDefEnum.ctl" and remove Val2 from the enum list.

4. Run "Read Binary.vi". The result will now be Val1, not Val3.

 

EDIT:

Should have added, I'm on Windows7, 64bit, Labview 2012 sp1

0 Kudos
Message 1 of 6
(3,997 Views)

I haven't tested, but I believe you. I found this bug here when reading XML and unflattening to a class that has a DAQmx device name in its private data

0 Kudos
Message 2 of 6
(3,993 Views)

I can reproduce this issue using your example in both LabVIEW 2012 and 2013. I am inclined to say that this is expected behavior because once the ctl file is modified and applied, we are essentially trying to cast a unknown object stored on disk into a class known to be different. Regardless of which item in the .ctl file is deleted, the item with a associated value of 0 is chosen as the default upon loading of the file because it is guaranteed to be there. With that in mind, I am not 100% sure this isn't buggy bahavior either. I will do some additional research and try to confirm one way or the other. 

Jeff L
National Instruments
0 Kudos
Message 3 of 6
(3,941 Views)
Solution
Accepted by topic author thutch79

It turns out that this is a known issue and has been documented in CAR 48516. 

Jeff L
National Instruments
Message 4 of 6
(3,881 Views)

CAR 48516 discussed in this thread was fixed in  LabVIEW 2014.  For a more complete list of bugs fixed in LabVIEW 2014, check the LabVIEW 2014 Bug Fixes. You can download an evaluation copy of LabVIEW 2014 at www.ni.com/trylabview/ or if you have an earlier version of LabVIEW installed and an active SSP subscription, you will be able to download the latest version of LabVIEW through NI Update Service.

 

Regards,

 

Jeff Peacock 

 

Product Support Engineer | LabVIEW R&D | National Instruments | Certified LabVIEW Architect 

 

0 Kudos
Message 5 of 6
(3,733 Views)

Awesome. Thanks for the update. When I get some time to play with 2014, I'll confirm that it fixes my issues.

 

Tim

0 Kudos
Message 6 of 6
(3,725 Views)