LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Diagram constant refnum flakiness

There are crash-level bugs in LabVIEW relating to refnum constants. These bugs cause LabVIEW 6.0.3 to crash during editing only. They do not affect runtime operation of the user code. They do make writing VIs quite fragile.

The attached file is a simple example. Look at the diagram. With your mouse, drag the "img params" constant over the "ch sel rings" array. LabVIEW 6 will crash immediately. Sometimes the crash takes a little bit longer.

These refnum constants are extremely useful in state machines. They serve as placeholders in the local variable cluster for the state machine. I drop them into the cluster and then assign them in an initialization phase. They can also be reassigned at runtime. These types of cons
tants are also very useful for file refnums, TCP refnums, etc.

As with the Formula Node editing problems (which also crash LabVIEW), editing VI diagrams with these constants is very crash-prone.

Mark
0 Kudos
Message 1 of 9
(2,904 Views)
Unless you use the refnum constant to explicitely define datatypes in the cluster, you can always use the constant "Not a Refnum" found on the file constants palette. "Not a Refnum" will typecast to any type of refnum you wire it to. After all the only useful value a constant refnum can take on a diagram is "Not a refnum".


LabVIEW, C'est LabVIEW

0 Kudos
Message 2 of 9
(2,904 Views)
The main problem with the idea is that not-a-refnum won't go inside a cluster. (See attached.)

Besides, even outside a cluster, not-a-refnum requires a typecast for every diagram usage. The typecast in turn requires a type constant or front panel control anyway. It is much better to use typed refnum constants. Code is simpler that way.

Try using not-a-refnum with VI Properties and you'll see the wire break. It won't break with file or TCP operations.

Other techniques I have used in the past include flatten-to-string and unflatten, as well as storing the refnums in hidden front panel controls. I have not found any solution that is more rational than using typed refnum constants. These make the most sense.

In any case, if NI offers a
feature, it should not crash LabVIEW when you try to wire it up. Refnum constants and formula nodes do that consistently when I edit them. I use a very clean Windows 2000 system with 512 MB RAM and fast hard drives. The problem is definitely LabVIEW.

Looking forward to 6.1,

Mark
0 Kudos
Message 3 of 9
(2,904 Views)
I was very specific in my first reply: "Unless you use the refnum constant to explicitely define datatypes...". That is obviously what you are doing...
A workaround to the crashing constant that you use is the "Class specifier constant" that you can set to the datatype you want. See attached VI.
By the way, I agree that LabVIEW should not crash when you use these features.


LabVIEW, C'est LabVIEW

0 Kudos
Message 6 of 9
(2,904 Views)
Yes you were. My point is that this usage (explicitly defining data types) is the most common and most important. In other words it is not an exception clause.

These diagram constants behave exactly like class specifier constants since that is what they are. They are more visually intuitive since they correspond to the front panel controls.

Mark
0 Kudos
Message 8 of 9
(2,904 Views)
How the heck did you get those constants on there?
0 Kudos
Message 4 of 9
(2,904 Views)
Ahh, that is a long story...it's like hunting for "Easter eggs" in Microsoft Office. I don't want to go into the details, except to say that NI really should make it easier.

Suffice it to say that you may right-click on one of these and change the type for use in your code.

Mark
0 Kudos
Message 5 of 9
(2,904 Views)
1) Create a new VI.
2) Place a control of the same type as you want the constant. (Refnums, waveform etc.)
3) Double-click on the control to open the control editor (don't forget to enabled "Open control editor with doubleclick" in the frontpanel options under Tools/Options...)
4) Drag and drop the icon from the control editor into any diagram where you want the constant.
5) Close the control editor without saving the control and close the Vi created in 1) without saving.

This also works with type defs. Just open the type def -> drag and drop the icon into any diagram.

Best regards,
Mattias Ericsson
Endevo Sweden
0 Kudos
Message 7 of 9
(2,904 Views)
Here are some further comments about the behavioral differences between class specifier constants, constant refnums, etc. There are some design inconsistencies in LabVIEW that should be cleaned up. -- Mark
0 Kudos
Message 9 of 9
(2,904 Views)