LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Wiring error after replacing typedef

Solved!
Go to solution

I encountered a problem replacing typedef with script. Simple test answered that the problem is not in scripting but in behavior of the altered BD. So, scripting is not needed to reproduce the problem.

 

This code does not do anything useful; it only illustrates the question:

img1.gif

The Case Structure has two cases. The second is here

 

img2.gif

 

Now I replace the typedef with new one:

img3.gif

 

 

But the wiring in second case is broken.

img4.gif

 

Attempt to rewire Wire 2 (i. e. delete it and connect terminals again) doesn’t help. The wire is still broken.

However, if I rewire Wire 1 or Wire 3, the problem disappears; i. e. Wire 2 suddenly becomes functional.

 

Could someone answer:

  • What is the reason for such behavior?
  • Could the problem be solved with scripting? Of course, a script can rewire but it seems like a dirty fix.

Attached ZIP contains test code created in LabVIEW 2020 SP 64-bit. The problem is the same with LabVIEW 2021 SP 32-bit.

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 1 of 10
(1,695 Views)

This is one of those nasty hidden problems with using the default value if unwired terminal option with uninitialized shift registers and improper initialization.

 

On first call there is a ref to a datatype which was a brown cluster <numeric values only and hence contiguous in memory>  that you replaced with a pink cluster <non contiguous memory>  then you try to access the pink cluster when the ref still expects brown.

 

Had you not chosen to use a default if unwired tunnel the code would have broken a bit more elegantly but, still broken properly. 

 

Basically you can't expect backward type propagation.


"Should be" isn't "Is" -Jay
Message 2 of 10
(1,672 Views)
Solution
Accepted by topic author _Y_

@JÞB wrote:

This is one of those nasty hidden problems with using the default value if unwired terminal option with uninitialized shift registers and improper initialization.

 

On first call there is a ref to a datatype which was a brown cluster <numeric values only and hence contiguous in memory>  that you replaced with a pink cluster <non contiguous memory>  then you try to access the pink cluster when the ref still expects brown.

 

Had you not chosen to use a default if unwired tunnel the code would have broken a bit more elegantly but, still broken properly. 

 

Basically you can't expect backward type propagation.


 

Thank you, I was thinking about back-propagation problem but was confused with Wire 3 (rewiring Wire 3 removed the error).

 

After your post, I suggested that combination of the  uninitialized shift register and hidden default (Use Default if Unwired) would be too much for LabVIEW internal intelligence. Such modification of the code solved the problem:

 

_Y__0-1650205523183.png

_Y__1-1650205688293.png

 

 

 

Unfortunately this solution is specific. It cannot be used as general.

 

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 3 of 10
(1,648 Views)

Just to satisfy my curiosity.   Try that old code replacing the typedef cluster with a new brown cluster.  Let's see if the LabVIEW internals are smarter than you think.

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 10
(1,630 Views)

Help me out because I'm not seeing what it is that makes the solution in msg #3 "more specific" than what you were trying to do in msg #1.   Either way, case 0 always creates a new DVR and on first call will also abandon the old map.  The only real difference I see is whether or not "Build Map" gets used, but that doesn't strike me as any more "specific" than the type of the map's value.

 

What am I missing?

 

(Note: I tried a different mod to your initial example, using a 0-iteration For Loop in the first call=True case as a trick for passing the map wire straight through while still outputting a default (empty) value.  But I got the same broken wire you had originally.)

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 5 of 10
(1,612 Views)

@JÞB wrote:

Just to satisfy my curiosity.   Try that old code replacing the typedef cluster with a new brown cluster.  Let's see if the LabVIEW internals are smarter than you think.

 


Replacing with:

- another typefew containing identical “brown” cluster doesn’t give any error

- replacing with non-typefefined  “brown” cluster doesn’t give any error

- replacing with non-typefefined  “pink” cluster gives any error

 

By the way, could your recommend reading about handling of contiguous and contiguous memory in LabVIEW?

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 6 of 10
(1,592 Views)

@Kevin_Price wrote:

Help me out because I'm not seeing what it is that makes the solution in msg #3 "more specific" than what you were trying to do in msg #1.   Either way, case 0 always creates a new DVR and on first call will also abandon the old map.  The only real difference I see is whether or not "Build Map" gets used, but that doesn't strike me as any more "specific" than the type of the map's value.

 

What am I missing?


Sorry, I probably posted unclear message using word "general" in relevance to such kind of problems.

 

My code cannot be general because it does not do anything. It is illustration, localization of the problem.

 


@Kevin_Price wrote:

(Note: I tried a different mod to your initial example, using a 0-iteration For Loop in the first call=True case as a trick for passing the map wire straight through while still outputting a default (empty) value.  But I got the same broken wire you had originally.)


Could you post an image of your solution? I cannot restore you idea from the text description.

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 7 of 10
(1,588 Views)

 

Could you post an image of your solution? I cannot restore you idea from the text description

 

Just place a for loop.with N wired to a zero and the map wired through.  Since the for loop doesn't execute the data fron the tunnel in buffer is never copied to the tunnel out and it outputs default data.

 

Don't  ask me to show you how.  Everyone knows that I don't write bugs.


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 10
(1,569 Views)

Here's the 0-iteration For Loop:

 

Kevin_Price_0-1650282560119.png

 

Funny, when I just re-did it I found both Wire 1 *and* Wire 2 broken.  I thought I rememberd only seeing Wire 2 broken before, like you.

 

Kevin_Price_1-1650282621027.png

 

 

-Kevin P

 

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 9 of 10
(1,563 Views)

Thank you, I did not think about such use of for loop.

 

Of course, if this solution works, it is more general then using Build Map.

 


@Kevin_Price wrote:

Here's the 0-iteration For Loop:

 

Kevin_Price_0-1650282560119.png

 

Funny, when I just re-did it I found both Wire 1 *and* Wire 2 broken.  I thought I rememberd only seeing Wire 2 broken before, like you.

 

Kevin_Price_1-1650282621027.png

 

 

-Kevin P

 


I had such effect in my tests too but do not remember sequence of steps causing it.

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 10 of 10
(1,528 Views)