07-22-2010 04:36 AM
Hello
I am quite new to Labwindows. I have a C++ windows console program that generates a Square wave signal and saves the data file as ".sig". When the program is run, the user enters the period and amplitude.
I need to integrate the same program in Labwindows. The GUI in Labwindows shoud look like this. See attachment.I have already created the user controls in gui, but i dont know how to integrate the C++ code ( like connecting the inpout in C++ program here in CVI gui input control.
any ideas?
07-22-2010 05:18 AM
Hi,
for integration of the GUI with your source code it might be helpful to look at the many samples provided with CVI. You can use the example finder and search for UI. You might want to start with the project simple.cws
Concerning your C++ code, you will need to manually change it to C code because CVI does not support C++.
07-22-2010 09:24 AM
Could you please give a small example for it? I mean .. i have gone through the examples available in CVi, but could not understand a thing,
Could you please give a short example project for this:
Adding two numbers. Here the user enters the two numbers in Visual C++ application. How can one select these inputs as control in a CVI GUI.
#include <iostream>
using namespace std;
int main()
{
int number1,number2,answer;
cout << "number1? ";
cin >> number1;
cout << "number2? ";
cin >> number2;
answer = number1 + number2;
cout << "Answer is " << answer;
}
----------------------
Number 1 & number 2 are two controls on User interface GUI in CVI. I am using a 2009 CVI version.
Thanks
07-22-2010 09:48 AM
OK,
here is a simple example.
07-26-2010 12:50 AM
Hi Nghtcrwlr,
Have you succeeded with your efforts?
07-26-2010 02:36 AM
Hi Wolfgang
Thnx for the example. I was trying to understand your example and to implement a similar one by myself. It was succuessful. Now am trying to find a solution for my question using this one.
Once something happens i will ask your help again.
Thankyou very much!!
07-26-2010 05:16 AM
Hey Wolfgang
Now i am trying soemthing else. Thought of doing the work step by step. I need to get display of an image based on the type of ring selected.
Here is the full code attached. when i select squarewave i need its image to be displayed. Is there something worng with my code??????
07-26-2010 05:38 AM
Hi,
it appears that your question is almost the same as the one posted here ? Duplicated posts will not speed up answers. Most contributors here are volunteers and may be busy...
07-27-2010 07:29 AM
Sorry Wolfgang. After posting it here only i recoginzed that it is better to post it as a seperate question . thats why i posted in in another thread. and unfortunately I forgot to delete it from here.
07-28-2010 03:11 AM
I have a generate button in tzhe front panel. When i click the generate button, i shoukd perform the following C++ code. COuld you please check whether this is correct. I have manually changed it to C code. But it is not working .
-.------------------------------------------------------------------------------------------------------
int CVICALLBACK GenerateCallback (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
double p ,a;
double square(const double x)
{
// Period and amplitude.
static const double period = (p/2);
static const double amplitude = a;
// Force positive argument.
const int neg = x < 0.0;
const double xx = neg ? -x : x;
// Scale the argument and compute the return value.
const double x_scaled = xx - floor(xx / period) * period;
const double ret_val = x_scaled < period / 2.0 ? amplitude : -amplitude;
// Antisymmetric square wave.
return !neg ? ret_val : -ret_val;
}
struct POINT
{
double x;
double y;
};
int main(int argc, char* argv[]) //; <= no semicolon here
{
unsigned int n;
//cout << "Maximum number of Samples = " << endl;
int no_of_points = 130944; // default value
//cin >> no_of_points;
//if(argc > 1)
//std::istringstream(argv[1]) >> no_of_points;
POINT* points = new POINT[no_of_points];
cout << "Enter the Period :\n";
cin >> p;
cout << "Enter the Amplitude:\n";
cin >> a;
int w ;
double g= 512;
//Create a file to write to
FILE *OutFile = fopen("Extern_stimulussignal.sig","w");
for(w=0;w<10;w++)
{
const double increment = 1.0;
points[0].x = 0;
points[0].y = square(points[0].x);
for(n = 1; n <= (128*g)/pow((double)2, w); n++)
{
points[n].x = points[n-1].x+ increment;
points[n].y = square(points[n].x);
printf("%12.7f\t%12.7f\n", points[n].x, points[n].y);
//Send data to file
fprintf(OutFile,"%12.7f\n", points[n].y) ;
//("%12.7f\t%12.7f\n", points[n].x, points[n].y);
}
}
//Close the file
fclose(OutFile);
cout << endl;
cin.get();
return 0;
}
break;
}
return 0;
}
-----------------------------------------------------------------------------------------------------------------------