LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to pass AI value to log file

I have a problem passing an AI value from a Fieldpoint module to print out to a log file. However I'm able to pass other values from a second panel on the UIR.

Is there something I'm missing or should I take a different approach when dealing with FPAdviseCallback function?


void CVICALLBACK FPAdviseCallBack(void* buffer)
{
IAByte* Databuffer;

FP_CallbackParamType g_param;
float* value;

int i,j;
/* See the Function Panel FP_Advise item "Callback Function" for more information
on this callback and it's data types*/

g_param = *((FP_CallbackParamType*) buffer);
Databuffer = g_param.buffer;

value = (float*)(Databuffer);
SetCtrlVal (panelHandle, PANEL_AI0, *value);

value = (fl
oat*)(Databuffer+4);
SetCtrlVal (panelHandle, PANEL_AI1, *value);
}


int CVICALLBACK configureUSER(int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{

switch (event)
{
case EVENT_COMMIT:
SetCtrlVal (panelHandle, CONFIGURE_USER, User);

GetCtrlVal (panelHandle, PANEL_USER, User);

}

int CVICALLBACK logFilebutton(int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{

switch (event)
{
case EVENT_COMMIT:

FILE * logFileptr;

/* Write to file */
logFileptr = fopen ("c:\\logfile.txt", "a");

fprintf (logFileptr, "\t%.2e", User);
fprintf (logFileptr, "\t%.2e", PANEL_AI0);
fprintf (logFileptr, "\t%.2e", PANEL_AI1);

fclose(bakeoutLogFilePtr);
}

The FpAdviseCallBack and configureUSER functions works fine in displaying the values in the panel. When I exectute the logFilebutton function it is able to write to the file but the "PANEL_AI0 and PANEL_AI1" send
values from their #define values. The "User" string in the log files works fine.
0 Kudos
Message 1 of 2
(2,944 Views)
In order to pass to the log file the value stored in the control instead of its ID you must retrieve the value in a variable with GetCtrlVal before outputting it to the file.

Another way could be to use two global variables (like User in your function, that is not defined elsewhere so I assume it's defined at module- or project- level) and store in them the values read from fieldpoint in FPAdvise; you can use them next in the program as you need.

Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(2,944 Views)