LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX creatable objects

Hi,
 
I have been trying to get our ActiveX control (Zipped and attached) for our USB system to work with Labview 7.1.
I have attached two vi files along with the ocx file.
 
The ActiveX.vi file works for the most part, but the Reg Event Callback block seems to get stuck in an OnConnect loop when the device is connected, yet doesn't execute the OnDisconnect routine or any of the others. At this stage the callback vi's are just dialog boxes. Also the callback vis do not have the same inputs/outputs as the _temp.vi file shows - is this the variant data? How do I typecast this to get the correct values out of it??
 
The ActiveX_temp.vi contains the desired event functions but produces "null refnum passed as input" errors.
 
Only the root property of the OCX file is creatable. From this though, several of the properties and methods are then available. However aside from providing basic info like PID and VID the really useful events like OnConnect, OnDisconnect, OnRead are inaccessible and the Event ActiveX Class is not creatable on its own.
 
We have a couple of applications written in VB that communicates with this OCX file and our USB system however VB seems to detect ALL the properties and methods available from the ocx file.
 
Some help with this would be appreciated...
 
 
J
 
PS I have read (nearly) ALL the posts on ActiveX and creatable objects but none have helped at all...
I have also looked at implementing this in VISA however this then dominates the system and our existing VB apps will not work with it.
0 Kudos
Message 1 of 19
(4,301 Views)
Hey J!

I would gladly take a look at your ActiveX control and program if you could attach it again.  Occasionally ActiveX properties and methods are accessible to VB and not to LabVIEW, mainly due to LabVIEW needing a specific format, whereas VB is slightly more flexible.  In any case attach away and I will check it out!

Andy F.
-----------------------------------------------------------------
National Instruments
0 Kudos
Message 2 of 19
(4,276 Views)
I thought I did attach them...
 
Here you go.
 
 
Download All
0 Kudos
Message 3 of 19
(4,266 Views)

Hi Andy,

The file has been modified somewhat since I last tried to attach it. The subVIs for the event callbacks only have the standard (generated) i/o variables and I included a simple dialog prompt to them to tell me when the module was being called.

The 'Write' section (bottom left) was just to try to send commands to the product as the protocol for this is defined and known. It still doesnt work, but I hope to have that sorted today... (maybe a little optimistic).

A certain amount of code debugging for this is hardware dependent but I will appreciate any help or suggestions you might have.

Thanks

 

Jared

"Chaos, panic and disorder - My work here is done."

0 Kudos
Message 4 of 19
(4,265 Views)
Hey Jared,

I took a look at your VI and as you mention was not able to get any results since I don't have any hardware for this, but I do have a few suggestions.  The first would be to enforce dataflow.  You can force nodes in your application to execute sequentially by wiring their error clusters together.  I don't think that this is going to solve the issues you are seeing, but it is good LabVIEW programming style.  The second would be to use an Automation Open to create the refnum for your ActiveX class.  You can do this by simply placing the Automation Open function on the Block Diagram and then right-clicking on the function and selecting Select ActiveX Class >> Browse... and then selecting your OCX file.  The callback VIs were not included, but I just wanted to make sure that you had created them by right-clicking on the Event that you wanted to register and select Create Callback VI.  There is a good example of ActiveX events in the Example Finder (just search for ActiveX Events).

Let me know if this helps!
Andy F.
-----------------------------------------------------------------
National Instruments
0 Kudos
Message 5 of 19
(4,251 Views)

Thanks for your suggestions Andy,

I typically tidy up all the sequencing and error cluster stuff after I have got the principle parts sorted out first. But your point is noted.

I thought I had tried this creating Automation Open approach and indeed I had (I repeated it just now). I cannot see our OCX control in the available list, and nor is it there if I de-select the Creatable Objects checkbox. I tried browsing for the ocx file and selecting it but this doesnt appear to do anything. If I place an Automation Refnum instead and select the ActiveX Class, it is available in the list here, but it still doesnt work and the error says it is passing a null refnum.

Yes, I had created callback VIs using the method you describe, and indeed obtained the how from that very example. I then included a dialog box in the callback vi to display "USB connected/disconnected/read/readerror" messages when the callback vi was being run.

Any further suggestions to help me solve this?

 

Jared

0 Kudos
Message 6 of 19
(4,234 Views)
Jared,

Unfortunately there isn't much else that can be done that doesn't involve editing the ActiveX class.  As I previously mentioned VB is much more flexible when calling ActiveX classes than LabVIEW is.  Would it be possible to set up a polling loop that would check to see if there is a connection or if there is a read/read error?  I know this isn't an ideal situation but it might be an effective workaround.  If you do have access to this class, I would suggest trying to see if there are any changes you can make that will allow the event to be fired.  There isn't a comprehensive reference about programming ActiveX for LabVIEW, so this might involve some trial and error. 

Let me know if you have any questions about this. 
Andy F.
-----------------------------------------------------------------
National Instruments
0 Kudos
Message 7 of 19
(4,223 Views)
Hi Andy,
 
That's not good news but I will have a look at trying this soon.
 
A simple question for you though -
I have managed with the help of one of the other software guys to sort out a temporary workaround. We modified the existing application (VB) that we have to save the current frame of data to a csv file. My vi then opens this, grabs the contents, and closes/deletes it. The VB app then re-creates it with the next current frame.
 
However as is the nature of a system like this, it relies on the file being there to be opened/read.
 
As a backup to this file not being there I mask the Open File error with a 'cancel error on match' in a General Error Handler.vi and suppress the dialog, then use a fixed system frame file instead. However the suppress dialog doesnt work and I am stuck with pop-up error dialog boxes.
 
Any suggestions?
 
Here are the vi and the two csv files zipped...
0 Kudos
Message 8 of 19
(4,207 Views)
Jarrod,

I am glad that you have a workaround for this issue.  I checked your code and I believe I might have a suggestion for you.  The pop-up dialog box you are receiving is a small box that complains about the file not being found is that correct?  If so there is an option on the Open/Create/Replace File VI that will allow you to allow or suppress advisory dialog.  If you create a constant from the "advisory dialog?" option and set that to False you will stop any error messages from that VI including the file not found dialog box.

Does this help with this error?
Andy F.
-----------------------------------------------------------------
National Instruments
0 Kudos
Message 9 of 19
(4,193 Views)
Indeed it does... thanks for this Andy.
 
Unfortunately the problems keep appearing.
I cannot get the app to run on a machine under Win2k. Unfortunately I do not have another machine with Win2k on it to see if it is a machine dependant or OS problem.
I have used the builder to build; created an installer; created an installer with all the options for including stuff ticked, and installed both runtime engine v7.1 and v8.as well...
 
It works directly from the installer on my XP laptop.
 
Any suggestions?
 
Jared
 
 
0 Kudos
Message 10 of 19
(4,179 Views)