bna08 Posted December 15, 2022 Report Share Posted December 15, 2022 (edited) I have multiple cases to be executed in a case structure as a result of user events in my application in a producer/consumer pattern. In one of the cases a new reference is created that I will only need once more in another case of the given case structure. All other cases have no need for that reference. However, if those other cases are invoked (e.g. Grab Frame, Stop Acquisition), a wire has to be dragged through the case from input shift register via case structure tunnels to output shift register so that it does not become invalid (Use Default If Unwired) and can be used once the case that actually needs the reference is invoked. This results in unnecessary wires (and often more of them) in other cases of the structure that pollute the diagram and have to be there just to carry the reference for any other case. Is there a way I could reduce this "pollution" and avoid dragging the wire through each case where it is not used at all? Here is an example: INIT VI generates a reference that I will need when calling the OPEN CAMERA VI so I pass it to next iterations via Shift Register: OPEN camera VI that requires the reference from INIT case: Other cases, such as Open Camera or Grab Frame have no need for this reference, yet it has to be dragged through these cases as well in order to pass the reference if I want to keep the reference value for future use: I could select Use Default If Unwired in these cases and not use the wire at all, however, that will set the reference value to null and I won't be able to use it anymore. Is there a way to solve this without dragging the wires in all cases of the structure? Edited December 15, 2022 by bna08 Quote Link to comment
ensegre Posted December 15, 2022 Report Share Posted December 15, 2022 imho linked tunnel and explicit wires through all cases is always the sane thing to do to avoid mistakes. Yes, to save wires you could certainly write your ref into a hidden indicator or into a global variable out of Init, and read the local/global variable in the open camera case, but I'd consider it bad practice and a recipe for future races and less readable code. 1 Quote Link to comment
Neil Pate Posted December 15, 2022 Report Share Posted December 15, 2022 As your application grows I would expect the need to pass additional state information between the frames of your VI. You could make a "Core Data" type cluster and put whatever you want inside that. Then you just have one wire that gets passed on the shift register. 1 Quote Link to comment
Lipko Posted December 15, 2022 Report Share Posted December 15, 2022 Or maybe and functional global variable? And store the refs and other future internal data there. This would be too cimplicated if you want to handle more "instances" of your camera functions though. 1 Quote Link to comment
bna08 Posted December 15, 2022 Author Report Share Posted December 15, 2022 1 hour ago, Neil Pate said: As your application grows I would expect the need to pass additional state information between the frames of your VI. You could make a "Core Data" type cluster and put whatever you want inside that. Then you just have one wire that gets passed on the shift register. Sounds like a good idea, thanks! Quote Link to comment
ShaunR Posted December 15, 2022 Report Share Posted December 15, 2022 5 hours ago, bna08 said: I could select Use Default If Unwired in these cases and not use the wire at all, however, that will set the reference value to null and I won't be able to use it anymore. Right click on the tunnel and select "Linked Input Tunnel>Create and Wire Unused cases" 2 Quote Link to comment
Phillip Brooks Posted December 15, 2022 Report Share Posted December 15, 2022 3 hours ago, ShaunR said: Right click on the tunnel and select "Linked Input Tunnel>Create and Wire Unused cases" I use it everywhere. This is one of the things many LabVIEW programmers I've met have never encountered. They ask me "what the f&ck is that little thing?" and after I explain it to them it shows up in all their code 🙂 Quote Link to comment
ensegre Posted December 15, 2022 Report Share Posted December 15, 2022 8 hours ago, ensegre said: imho linked tunnel me first Quote Link to comment
kej Posted December 22, 2022 Report Share Posted December 22, 2022 On 12/15/2022 at 11:16 AM, Phillip Brooks said: I use it everywhere. This is one of the things many LabVIEW programmers I've met have never encountered. I resemble that remark. Best holiday gift so far this year. Thank you! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.