Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating CWDIO controls programmatically

I have two test fixtures that have different devices on them but I want to transfer my code back and forth when I can. Fixture A has a device 5 and fixture B doesn't. Once I use the property pages to set up the CWDIO control and give it a member variable all the calls to that member varaible work great. If the member variable is m_dio then m_dio.SetDevice(3) for example works great.

What I want to do though is only have device 5 on one station so I don't have to delete the control when I go from Fixture A to Fixture B. Right now I just change my #define FIXA to #define FIXB and recompile to switch fixtures. Well, everything works except for device 5 which is on FIXA and not FIXB. Well, the solution seems to be just don't
have a device 5 and only create one for use on FIXA.

I have the following in my .h.

CCWDIO m_diocontrol;

then in my *.cpp OnInit() I have:

m_diocontrol.SetDevice(5);

when I call
device = m_diocontrol.GetDevice();

device equals like 0x10003 or something and changes around which seems like it must not be getting assigned at all.

I have all the instruments working through MAX and like I mentioned before if I use the property pages of a dialog control I don't have a problem.

So, all this so I don't have to delete the control or recreate it each time I go between fixtures. Seems like I should be able to do it though.

Should I be trying more of a dynamic approach? I'm sure you can tell by my syntax that I'm more of a test engineer then a programmer. I appreciate your input.

Grant

ps. I should mention that device 5 is another PCI-6503 card. FIXA has 2 PCI-6503 cards and FIXB only has one so no device 5 for him. Since both have at least one PCI-6503
though all the files are installed for digital I/O.
Grant M. Johnson
Project Engineer
LECO Corporation
0 Kudos
Message 1 of 2
(2,804 Views)
It sounds like that the control may not be getting completely initialized - are you doing anything else to initialize the control beyond calling the constructor? Specifically, I think that you need to call Create. For more information and an example of how to do this, see the Developer Zone article Embedding a Dynamically Created Licensed Measurement Studio ActiveX Control in a Visual C++ Dialog .... This article discusses dynamically creating a graph control, but I
think the same ideas apply to dynamically create a DAQ control.

- Elton
0 Kudos
Message 2 of 2
(2,804 Views)