//*****************************************************************************
// Labwindows/cvi8.5 白噪声发生器
// szlihongtao
// 2010-07-29
//*****************************************************************************
#include <userint.h>
#include <ansi_c.h>
#include <analysis.h>
#include <cvirte.h>
#include <userint.h>
#include "t.h"
//*****************************************************************************
static int panelHandle;
double amp;
unsigned int cnt;
double seed;
double *wave;
//*****************************************************************************
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "t.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
//*****************************************************************************
int CVICALLBACK GenerateWave (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
{
GetCtrlVal (panelHandle, PANEL_AMP, &);
GetCtrlVal (panelHandle, PANEL_SEED, &seed);
GetCtrlVal (panelHandle, PANEL_NUM, &cnt);
wave=malloc(cnt*sizeof(double)); // 申请内存
WhiteNoise (cnt, amp, seed, wave); // 产生白噪声
DeleteGraphPlot (panelHandle, PANEL_GRAPH, -1, VAL_IMMEDIATE_DRAW);
PlotY (panelHandle, PANEL_GRAPH, wave, cnt, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
free(wave); // 释放内存
break;
}
}
return 0;
}
//*****************************************************************************
int CVICALLBACK mexit (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}
//*****************************************************************************
//*****************************************************************************
//*****************************************************************************
用户377235 2013-1-30 17:40