06-12-2006 06:20 PM
06-12-2006 07:22 PM
06-13-2006 02:00 AM - edited 06-13-2006 02:00 AM
With reference to program2
The first solution you have posted is the right one: user_seln is filled with a proper value at every iteration of the loop. In your second solution, if birdFrameReady is not true the variable is not filled with any value when tested in the while clause, so the compiler warns you for this. You could avoid this warning inizializing user_seln to 0 when declaring it, but in your aplication you do need to test the button at every loop iteration so you need to run the first structure of code.
Which type of button is MPANEL_DATAFLOW? Since it's probable that your loop is quite long lasting, you may not find the button in the correct state when you test it if you use a standard button: I suggest you use a toggle button instead, so that its state is maintained once pressed and whenever the program has time to test it, it finds it in the right state. Of course you will need to reset its state when exiting the loop with SetCtrlVal (mpanel, MPANEL_DATAFLOW, 0);
With reference to program11
Is MPANEL_DATAFLOW the button to which GETHEADTRACKERDATA callback is associated? If so, you need to test its value to start acquisition only when it is true (a toggle button fores a EVENT_COMMIT event every time its state is changed!).
Looking at the code it's not simple to detect what's happening: you may need to place breakpoint inside the timer callback on birdStartFrameStream row so that if the timer is running the correct way the program will break when acquisition is enabled.
In my opinion you should place acquisition stopping routine outside the timer callback: the way it is structured now, it will execute birdStopFrameStream and birdShutDown at every execution if timerflag is 0!
Try this different approach:
GETHEADTRACKERDATA (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
static char pathname[MAX_PATHNAME_LEN], dirname[MAX_PATHNAME_LEN];
int status;
int user_seln, sts;
if (event == EVENT_COMMIT) {
GetCtrlVal (panel, control, &sts);
if (sts) {
HidePanel(panel2);
GetCtrlVal (panel2, PANEL_2_SAVEDATA, &fileFlag);
if (fileFlag) { /*Save data is fileFlag is enabled*/
GetProjectDir (dirname);
status = FileSelectPopup (dirname, "datafile.txt",
"Datafiles (*.txt)", "DataFile Storage",
VAL_SAVE_BUTTON, 0, 1, 1, 1, pathname);
datafilestream = fopen (pathname, "w+");
DisplayPanel (mpanel);
}
else {
birdStopFrameStream(GROUP_ID); /*Stops streaming of bird data frames*/
birdShutDown(GROUP_ID);
// Add all necessary instructions to stop the acquisition
}
return 0;
}
Message Edited by Roberto Bozzolo on 06-13-2006 09:18 AM
06-13-2006 08:20 AM
06-13-2006 09:17 AM
Hi,
Also as i was mailing u i thought of using this idea using C programming. Although it would not use labwindows i could still achieve offset correction.
int i=0
do{
//instructions for initialising the headtracker
if(i=2000)
{
//instructions for offset correction
}
//instructions for printing value to screen
i++;
}while(user_seln==1);
since the headtracker streams data at 120 Hz or 8.3 ms each time it executes do loop it will be incremented by 1. so by i=2000 it would give operator about 16 sec to set the headtracker at correct postion before offset correction starts. Also the offset correction would be set only once at i=2000. Do you think it is a good idea. However it still doesn't solve the problem of gaining control over my uir.. and using the switch DATAFLOW still if of no use. I still have to try my above mentioned code as i would be in my lab by evening. However could u suggest some more modifications on the same. The only thing i feel using it is that it would not be user friendly.Do you have something in labwindows that could better it
Kunal
06-13-2006 10:24 AM
06-13-2006 07:59 PM
06-15-2006 07:56 AM