Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

application distribution Measurement studio

We have now developed a software application using Measurement Studio and VC++ for "capturing" live communication data from line as step 1 of the application and "analysing data" separately as step 2. We can do the 2 steps without any problem on a data acquisition machine. However, when we run the same application on a desktop PC (not a digitizer or not connected to digitizer) we expect the application to RUN only step 2. The question here is then, in order to set application up on a desktop PC (not a digitizer or not connected to digitizer) what changes I should do (in terms of un-tying NI scope acquisition functions)?
NI Software : Measurement Studio for Visual C++ version 7.0
NI Hardware : High-Speed Digitizers (Scopes) device PXI-5122
Driver Version : NI Scope 2.6
OS : Windows XP
0 Kudos
Message 1 of 9
(4,915 Views)
When building an application that uses the scope import library, your application will automatically try to load up the scope driver dll at startup. So if you try to run an app built in this manner on a PC that does not have the scope driver installed, you will get fatal errors when launching the errors.
Instead of using the import library, load the scope functions at runtime instead of loadtime by using LoadLibrary() and GetProcAddress(). Load the appropriate libraries only when you need to. Plus this way, you have more control over handling the Loadlibrary function failing, in case the dll was not found.
The documentation for the scope driver will provide you with the name of the driver dll that contains the appropriate functions.

Hope this helps
Bilal Durrani
NI
0 Kudos
Message 2 of 9
(4,899 Views)
Bilal, Thank for your response. Can you help me a little more in detail with your response. You are in right that the application does crash if I try to open it from a PC that does not have the scope driver installed.

>>>> Instead of using the import library, load the scope functions at runtime instead of loadtime by using LoadLibrary() and GetProcAddress().

You mentioned that library is imported at load time, can you tell me where in code or VC++ setting does this occur and how should I clear this import.

>>>> Load the appropriate libraries only when you need to. Plus this way, you have more control over handling the Loadlibrary function failing, in case the dll was not found.

Can you tell me how and where I should set this up when you say load library at run time?

In this effect I tried something that I want to share with you. Essentially, I enclosed the scope part of the code in an if statement based on a boolean. To identify if scope is connected and to subsequently set the boolean, I instantiated an CNiSCope object in MainFrm class by a simple function call. If this call threw an exception, I assumed scope was not available for machine and set the boolean. Using this boolean, I then DID NOT create scope user interface in the application for PCs without scope. In other words, the application decides at runtime based on the exception thrown. This works fine in the sense that I can startup the application with NI user interface activeX controls (knobs, graphs, sliders) on PCs without scope controls. But the application crashes when try to begin the analyses part of application. I guess it crashes while accessing NI Measurement Studio data types such as CNIVector, CNiMatrix, CNiReal etc that it requires at runtime. I found this crash point by using the debugger in VC++. I am assuming if I load the NI data types as well I should be fine. Is this correct?

I assume the above is what you meant by loading at runtime. Please correct me if I am wrong.

The other questions I have is regarding installer. I am using the MS VC++ .NET 2003 installer for packaging my application. I am wondering at what step is the dll files needed in packaging because they never mentioned in instructions (NI knowledgebase document ID: 341AEOW3) about including "dll" files. As mentioned above I am at this point able to use the installer and package application but facing the problem I described above only when application starts the analyses action.

Thanks

Murali
0 Kudos
Message 3 of 9
(4,889 Views)
And forgot to mention, Delay loading works well too.
Bilal Durrani
NI
0 Kudos
Message 4 of 9
(4,886 Views)
I have two questions.

One is regarding the MS VC++ .NET 2003 installer for packaging my application developed using Measurement Studio. I am wondering at what step is the dll files included for installation package because they never mentioned in instructions about including "dll" files (NI knowledgebase document ID: 341AEOW3 - "How Do I Disribute a .NET Application that Contains Measurement Studio Controls?")

Second is regarding, during runtime, when I startup the application with NI user interface activeX controls (knobs, graphs, sliders) get loaded on PCs without scope controls. But the application crashes when try to begin the application. I observed that the application crashes while accessing NI Measurement Studio data types such as CNIVector, CNiMatrix, CNiReal etc that it requires at runtime. What are the files that I am missing in my installation package that causes application to crash?

Please help

Murali
0 Kudos
Message 5 of 9
(4,839 Views)
Aha, I didnt realize that you were using the C++ scope classes. The scope driver does not get loaded until the very first call to the scope class. So you would not need to setup delay loading nor would you use LoadLibrary or GetProcAddress. You will get an exception when you use the CNiScope constructor and if the system does not have the scope driver installed.

Are you using the .NET class libraries? Or is this just MFC code? For a list of components that need to be distributed, refer to the Measurement Studio Help topic Distributing Measurement Studio Visual C++ Applications. Are you checking for exceptions when you start the analysis routines? Is this crash happening on the development machine or the deployment machine? Could you provide more information about the crash, perhaps a code snippet or a sample app ( with only the analysis section).

Thanks
Bilal Durrani
NI
0 Kudos
Message 6 of 9
(4,832 Views)
THanks for response.

>>> Aha, I didnt realize that you were using the C++ scope classes. The scope driver does not >>> get loaded until the very first call to the scope class. So you would not need to setup >>> delay loading nor would you use LoadLibrary or GetProcAddress.

Our application was developed using MFC VC++ 2003 .NET edition. Sorry I missed the details.


>>> You will get an exception when you use the CNiScope constructor and if the system does >>> not have the scope driver installed.

Exactly, I do get an exception when I use the CNiScope constructor. However, what I do is create CNiScope 2 times. The first time a dummy construction is done with function like this...

bool CMainFrame::ScopeExists(void)
{
bool scopeExists = true;
CString errorMsg = "NiScope device absent.\r\nNo Scope controls will be available";
try
{
// Instantiate a scope to test is it exists
CNiScope ProbeScope ("PXI1Slot2", false, false, "");
}
catch (CNiIviException* e)
{
e->Delete();
AfxMessageBox (errorMsg, MB_OK | MB_ICONEXCLAMATION);
scopeExists = false;
}
return scopeExists;
}


I use the returned boolean to identify if scope driver is PRESENT or ABSENT in the system. Using this boolean result I then do the actual scope dialog bar and CNiScope construction (the second time is when the actual CNiScope is created and used).
If boolean is FALSE
no scope dialog bar controls is created
only the analyses dialog bar controls are created
else
application starts up with scope and analyses dialog controls


>>> Are you using the .NET class libraries? Or is this just MFC code?

Just MFC code with Measurement Studio


>>> For a list of components that need to be distributed, refer to the Measurement Studio Help topic Distributing Measurement Studio Visual C++ Applications.

This was helpful to the extent that I got the active X controls loaded and distributed with application. But analyses part of application crashes when it tries to use the CNi such as CNiMatrices, CNiReal64Vector. I found this using the debugged in Microsoft's VC++ .NET 2003.


>>> Are you checking for exceptions when you start the analysis routines?

I do have a few exceptions being checked. However, can you tell the exceptions you have in mind that need to be included.


>>> Is this crash happening on the development machine or the deployment machine?

The crash is happening only on machines NOT having scope drivers. I tried on a 2 machines.
One WITH Measurement Studio and WITHOUT scope controls - it crashes
Second WITHOUT Measurement Studio and WITHOUT scope controls - it crashes
Is there something I am missing??


>>> Could you provide more information about the crash, perhaps a code snippet or a sample app ( with only the analysis section).

Here is code snippet....
m_digIntpolRowLength and m_digIntpolCoeffRows are unsigned int types.
m_farrowFilterCoeff is CNiReal64Matrix type. This is the first moment in application when a CNi is used. When the matrix elements are loaded with values, it crashes at the line
m_farrowFilterCoeff(0,0)=0.00252;.....

I know this may or may not give you whole lot of information. If we can go offline from discussion forum (becuase of proprietary information), I can provide more details about application etc. Thanks.

void CDAQ_DigitalInterpolator::ResetLarge(void)
{

m_digIntpolRowLength = c_digIntpolRowLengthLarge;
m_digIntpolCoeffRows = c_digIntpolCoeffRowsLarge;

m_farrowFilterCoeff.SetSize(m_digIntpolCoeffRows, m_digIntpolRowLength);
m_delayLineBuffer.SetSize(c_delayLineBufferSize);
m_delayLineSize = m_digIntpolRowLength;
m_delayLinePtr = &m_delayLineBuffer[c_delayLineBufferSize - m_delayLineSize];

/////Row 0//////
m_farrowFilterCoeff(0,0)=0.00252;
m_farrowFilterCoeff(0,1)=-0.0087823;
m_farrowFilterCoeff(0,2)=0.0218283;
m_farrowFilterCoeff(0,3)=-0.046127;
m_farrowFilterCoeff(0,4)=0.0909993;
m_farrowFilterCoeff(0,5)=-0.1884611;
m_farrowFilterCoeff(0,6)=0.6283543;

.......
0 Kudos
Message 7 of 9
(4,825 Views)
There really is no connection between the scope driver (im assuming thats what you refer to when you say scope controls) and the measurement studio analysis and CNi datatypes. They are independant of each other.

The analysis libraries get embedded into your exe, since they are static libraries and you dont need to distribute anything additional for them. The CNi data types are templatized classes and these are compiled into your exe as well.

Make sure that you are initializing your CNi data types correctly. Since these are not intrinsic types ( although they behave like them), they still need to be explicitly initialized at some point. Im not sure about your code path but this could be one thing to verify. Make sure in the case where the scope driver is not installed, you are still initializing the CNiMatrix type to the appropriate size.

If you are still running into these problems, you can send an email in by going here and include a really simply sample project we could use to reproduce the problem.

Hope this helps
Bilal Durrani
NI
0 Kudos
Message 8 of 9
(4,806 Views)
Bilal,

The problem was finally solved. It was NOT related to the data types such as CNi. It was all related to the project properties set in VC++ .NET environment. There seem to be some caching of information from previous bad runs that was causing it to fail. I don't know from which previous run though. First, I figured out how to get the debug mode of project executing correctly by comparing with another working sample code. To get the release mode of the project executing correctly it was painful. If you have some useful information describing about those project properties (a link or something) it will be helpful. Thanks for your help. I now have our application running WITH scope controls on a digitizer and the same application running WITHOUT scope controls on a desktop PC without scope drivers.

Thanks
Murali
0 Kudos
Message 9 of 9
(4,777 Views)