int CVICALLBACK plotFrequency (int panel, int control, int event, //plot frequency and power function
void *callbackData, int eventData1, int eventData2)
{
double tempMinFrequency;
ssize_t maxFrequencyIndex,temp;
double maxPowerValue;
int FFTplotHandle;
ssize_t inputSize = mSize ;
double *Measurement_fft_output= (double *)malloc (inputSize * sizeof(double)); //the declaration for the size of the holding array for the data collected.
if (inputSize > 0 ) //if function for input size larger than 0.
{
}
switch (event) //switch case for the data obtained to display on the graph.
{
case EVENT_COMMIT:
Copy1D (Measurement_Window_Data, inputSize, Measurement_fft_output );
//function to copy the data collected from Measurement_Window_Data into the array Measurement_fft_output
Spectrum (Measurement_fft_output, inputSize); //function to calculate the Power of the data obtained
int half =(int)(inputSize/2)+1;
Subset1D (Measurement_fft_output, inputSize, 0, half, Measurement_fft_output);
//function Subset1D to not duplicate the result data when plotting on the graph
MaxMin1D (Measurement_fft_output, inputSize, &maxPowerValue, &maxFrequencyIndex, &tempMinFrequency, &temp);
//function to find the max power of the data obtained on the graph.
SetCtrlVal (panelHandle, PANEL_MaxFrequencyBox, maxFrequencyIndex);
//function to display the Max Frequency value
SetCtrlVal (panelHandle, PANEL_MaxPower, maxPowerValue);
//function to display the Max Power value
RefreshGraph (panelHandle, PANEL_PowerSpectrum);
//function to refresh the graph to display new graph from the new chosen data
//it removes any plots deleted using DeleteGraphPlot
FFTplotHandle = PlotWaveform (panelHandle, PANEL_PowerSpectrum, Measurement_fft_output, half, VAL_DOUBLE, 1.0, 0.0, 0.0, 1.0,
VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
//platform to display the graph
SetGraphCursorIndex(panelHandle, PANEL_PowerSpectrum,1,FFTplotHandle,maxFrequencyIndex);
//function to display the cursor to visualize the max power value on the graph
DeleteGraphPlot (panelHandle, PANEL_PowerSpectrum, FFTplotHandle, VAL_DELAYED_DRAW);
//function to delete the old graph.
break;
}
return 0;