08-06-2008 12:56 PM
08-06-2008 01:26 PM
08-06-2008 01:32 PM
08-06-2008 02:50 PM
08-08-2008 12:48 AM
08-08-2008 02:46 AM
Hi Snowdust/ Peter K.
I have been experiencing similar problems using ActiveX to access a COM Object for communication with an external hardware module. I created a Cluster in the top Level Vi to store the reference and then generated the refnum in a SubVi using the Automation Open function and before exiting the SubVi stored the refnum in the Top Level Cluster (via Local Variable) prior to exiting the SubVi. Although I had not closed the reference (Close Reference function) the refnum seemed to be lost.
Question to Peter K. Is there a way around this problem where I don't have to hardwire the Refnum as I the design is highly architectural and hardwiring would be very messy (and cumbersome)? Would creating (and storing in the cluster) the refnum in the Top Level Vi make this available for use in all SubVi's within the Hierarchy of the Top level Vi?
Regards
Ian Melville
08-08-2008 01:24 PM
08-08-2008 02:05 PM
I'm not convinced these are both the same issue.
Ian's issue may be realted to LV clean-up routine If the VI that is opening the resource goes idle, all of its allocated resource are marked as invalid. You have to make sur ethe enitity that opens a resource is active as long as the resource will be used. That issue can be handled using an Action Engine.
Some screen shots will help up chase down these issues. Please post png or jpg since not all of as viewers for pdf's.
Ben
08-08-2008 07:48 PM
08-09-2008 08:36 AM
FIrst I would again urge you look into the Action Engine. Set it up such that is has an Init method, methods for each call,.... and also a close method. Keep the ref in a shift register inside the AE (works like a static local) and make all of your calls to the dll using the AE. This way you just have to update the AE with you re-compile.
Another thing that could help you is to use Type-Definitions for you ref num. I wrote about those in another Nugget that can be found here. They let you make the change once and the change is realized everywhere the type-def is used.
THe recompiling makes sense and is correct. LabVIEW enforces all of the details associated with function call protypes etc. so as a developer you just wire and run. Burried inside you refnum is the info for the calling standard. By forcing you to redifine the refnums, LV is helping you ensure you dod not do an illegal function call that could result in very bad things happening.
Ben