LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mock init/teardown of a device with fake references

I would like to write a mocking FGV function for initialization and teardown of a device which remembers the refnun and

passes it back on demand. However i don't know how to provide sentinals for a valid refnum and an invalid one.

For example i simply could use a refnum constant from the reference submenu in the frontpanel elements palette.

As this constant is merely a NULL ptr with a type, this would function as the second sentinal.

The other sentinal i thought could be provided by f.e. casting of an integer with a value of 1 to the refnum type.

However this leads to a complete exceptional termination of the labview dev environment.

The fake refnums are used only in mock vis and there is no property/invoke node wired to them.

 

Download All
0 Kudos
Message 1 of 3
(2,721 Views)

Hi Labuser,

 

what about creating simple refnum constant with a standard right-click on a wire/tunnel?

It will create an "empty/invalid" refnum of the required type…

 

(And there is a function to test for invalid refnums!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(2,711 Views)

Yes, but the calling vi (also a mock vi) contains two parallel while loops where the second terminates on error.

An error is produced by the subvi when the reference is read but was set back to it's standard value, before.

To check, if an error should be returned the vi "not a number/path/refnum?" is used.

The crash happens, when this vi is called with the ref wire containing the casted "1".

Therefore i need two dintinguishable refnum values although they are not generated from a real init function but only mocked.

 

0 Kudos
Message 3 of 3
(2,707 Views)