LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Not A Number/Path/Refnum? Function does not work with an SE reference

Solved!
Go to solution

Hi All,

 

I'm writing a LabVIEW application and want to check that the Switch Executive session is valid before I allow the user to commit the test to run. I connect the Not A Number/Path/Refnum? Function to the SE session reference and this connects correctly but the output of the function never goes false even though I can see that the session reference is valid and non zero. Any ideas why this is?

 

Thanks,

 

Nick

0 Kudos
Message 1 of 8
(3,701 Views)

Hello Nick,

 

This might be because that the NISE Session Out  is a strict type reference to string ( from context help, Data type of wire shows, as "datalog file reference of string") and 'Not A Number/path/Refnum function' is checking for valid path or not.

 

I connected the ‘Refnum to Path Function’ to the NI SE Session Out, it returned as “Not a Path”.

 

Hope this gives some idea about why the ‘Not A Number/path/Refnum function’ is returning as True.

 

Thanks,

sriveni

 

0 Kudos
Message 2 of 8
(3,678 Views)
Solution
Accepted by topic author nickstorton

It used to be a trick to typecast an internal reference in an external shared library (usually a memory pointer) into a strict typedefed datalog refnum. This safely prevented a user from connecting anything but this type of refnum to the VI in question. But it wasn't really a datalog refnum and the Not a Number/Path/Refnum determines based on the refnum subtype, which subsystem to query for the validity of a refnum. The LabVIEW datalog manager never created this refnum and therefore will correctly return (not one of my refnums that is currently known to be valid).

 

Because of this problem the misuse of datalog refnums as a unique resource identifier has been more and more abandoned in recent years. Also it won't work at all for external resources that represent memory pointers when using LabVIEW 64 bit, since memory pointers are 64 bit large in that environment while LabVIEW refnums are always 32 bit.

 

Check with NI if they have a newer version of the Switch Executive in the making or maybe already released.

Rolf Kalbermatter
My Blog
Message 3 of 8
(3,657 Views)

Hi Rolf,

 

Thanks, that makes it clear. I'm using a workaround at the moment by comparing the SE reference to a SE reference constant, if they are equal then it's not a valid reference, if they are not equal then I have a valid reference. I will check with NI as you suggest.

 

Thanks again,

 

Nick

0 Kudos
Message 4 of 8
(3,650 Views)

@nickstorton wrote:

Hi Rolf,

 

Thanks, that makes it clear. I'm using a workaround at the moment by comparing the SE reference to a SE reference constant, if they are equal then it's not a valid reference, if they are not equal then I have a valid reference. I will check with NI as you suggest.

 

Thanks again,

 

Nick


This is a good workauround. It is however not fully equivalent to Is Not A Number/Refnum/Path. You have the canonically invalid refnum which has never been initialized. This is your refnum constant. Its internal value is 0. Then you have a refnum that has been created but in the meantime got deleted/destroyed/closed. Its internal value is not equal to 0 but it is still not valid anymore.

Is Not a Refnum determines for both correctly true (if it is a real LabVIEW refnum and not a faked one), your comparison only will show true for the first case.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 8
(3,622 Views)

Hi Rolf,

 

As you say this is not fully equivalent to Is Not A Number/Refnum/Path but I do hold the session ID in a shift register and have checks in place in other functions to control the SE session. I know where I should be closing sessions and where I open new sessions so that should be all good. If something outside my control closes or invalidates the SE session then the next SE call will throw an error and stop the application anyway and pass the error info back to the UI so whilst it's not quite as clean as I originally wanted I cannot see a better way of dealing with this at the moment. That is unless you have a better suggestion.

 

Thanks for taking the time to discuss this,

 

Nick

0 Kudos
Message 6 of 8
(3,589 Views)

I'm not familiar with SwitchExecutive but in my own code I usually exported a function from the external code library which did the equivalent of Not a Refnum, by using it's internal verification mechanisme for checking if a passed in refnum was still valid. It's not as elegant as a true LabVIEW integrated refnum, but serves its purpose.

 

However as you can guess I abandoned the faked datalog refnum trick some time ago and use now another system.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 8
(3,575 Views)

I find that it is better to just let one of the Switch Executive VIs throw an error when the reference becomes invalid.  I have heard of some weird race conditions where somebody checked for a valid reference but the reference was closed by a parallel process somehow between the checking for a valid reference and actually using the reference.  So an error happened anyways.  So it was concluded that it was best to just try to use the reference and handle any errors that happen if the reference was invalid.  That exact example was with a queue, but the same concept applies to all references.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 8
(3,562 Views)