LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

events

I have a command button which calls a function in a dll on event commit. If the user presses the button several times to step through data values the function appearsto be processed in reverse order. There is a delay within the function while action on equipment occurs, the data values are set correctly then once the process completes the values from the earlier presses are sent to the equipment. is there any way to lose the data from the previous button pushes?

 

0 Kudos
Message 1 of 5
(2,837 Views)

There is no way to alter the scheduled events once they are put in the queue, what you may want to do is to avoid calling DLL function until it has finished handling previous requests. There may be several ways to do so depending on wether you can modify the DLL or not: basically you must find a condition thet informs you that the function has finshed and skip DLL function call until this moment.

 

This being said, your observation about the reverse order events are processed puzzles me: events are normally put in the queue in the order they are generated and handled in FIFO order, so you may want to investigate a little bit more what causes that strange behaviour.



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 5
(2,832 Views)

Still having callback problems!

I have found the cause of the problem but need help with a soultion.

 

I have a user operated command button which on EVENT COMMIT calls a function. this function has a timed delay to allow a process to start. within this timed delay loop is a PROCESS SYSTEM EVENTS so another press of the command button can be detected.

If I watch the values in the function call (in the event commit callback) the values appear to move to the last commanded value then step back through the previous events. If I leave the "Process system events" out of the loop all is ok but the key presses are not detcted.

 

HELP

 

0 Kudos
Message 3 of 5
(2,803 Views)

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;
}


0 Kudos
Message 4 of 5
(2,794 Views)

Discussion on this topic contitnues in this thread.



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 5 of 5
(2,783 Views)