Simple uir project to demonstrate the problem described in previous posts
Clicking the "increase" button sets a new value and starts a delayed time routine
one clcik works fine
but several presses (quick) causes the diplayed value to show final value for delayed period then steps back through to 1st clicked value (in sequence).
Please explain and help ?
Many thanks
I have copied and pasted code here at attachments are not being allowed by ni web site
error message
The attachments content type (application octet) does not match its file extension
//----------------------------------------------------------------------------------------
int Routine (double rtvalue)
{
//routine to wait for a set time
//
double timeout = 5.0; //alow 5 seconds for time out of loop
double time_start; //time value at start
double time_now; //time value
int abort = 0; //end of loop detect
GetCurrentDateTime (&time_start) ; // get now as utc seconds
SetCtrlAttribute (phPANEL, PANEL_NUMERIC, ATTR_CTRL_VAL, rtvalue);
ProcessDrawEvents();
do {
SetCtrlAttribute (phPANEL, PANEL_ldLoopRun, ATTR_CTRL_VAL, 1);
SetCtrlAttribute (phPANEL, PANEL_NUMERIC, ATTR_CTRL_VAL, rtvalue);
GetCurrentDateTime (&time_now) ; // get now as utc seconds
if (time_now > time_start + timeout)
abort = 1;
Delay(1.0) ;
ProcessSystemEvents(); //must be here to detect multiple presses of button
} while (abort < 1);
SetCtrlAttribute (phPANEL, PANEL_ldLoopRun, ATTR_CTRL_VAL, 0);
SetCtrlAttribute (phPANEL, PANEL_NUMERIC, ATTR_CTRL_VAL, rtvalue);
ProcessDrawEvents();
return 0;
}
//----------------------------------------------------------------------------------------
int CVICALLBACK clbk_Button (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
double value; //value of numeric control
double step = 5; //default step size
switch (event)
{
case EVENT_COMMIT:
count ++;
SetCtrlAttribute (phPANEL, PANEL_nCommit, ATTR_CTRL_VAL, count);
GetCtrlAttribute (phPANEL, PANEL_NUMERIC, ATTR_CTRL_VAL, &value);
value = value + step; //set value = current value + step
Routine(value); //send value to routine
break;
}
return 0;
}