EVENT_COMMIT or EVENT_VAL_CHANGE

I have a digital control. When the value is passed to IUR I store the changed value in a world. Now the same control can be updated from a different location. So lets say that the value of control has been replaced by 5. numGlobal = 5; Then, I read numGlobal and add 10. Now, the control should display 15.

EVENT_COMMIT or EVENT_VAL_CHANGED should be used? will be that the event should be swallowed after that value is passed to control every time. Any suggestions how?

TIA.

I don't understand exactly who is the problem.

Given that your value is stored in a global variable and the program you handle it, you only need to take into account the programmatic changes in control, so a simple SetCtrlVal should be sufficient without need for a special event.

If instead you have a reason to use the recall of order (which can include other instructions you want to be executed when using changes programmatically as well as when using the command for example) I suggest you use CallCtrlCallback, transmission of the event that you have coded in the callback control, in this way:

double value;

GetCtrlVal (panel, control, &value);
value += 10;
SetCtrlVal (panel, control, value);
CallCtrlCallback (panel, control, EVENT_VAL_CHANGE, 0, 0, 0);

CallCtrlCallback is part of the box tool of the programming interface.

Tags: NI Software

Similar Questions

  • Updating of increment (ATTR_INCR_VALUE) a control digital while holding the mouse button

    Hallo,

    It is a problem with a digital command.

    I have a control that accepts a broad range of values: 0.01 to 60000.

    What I want to do is changing its incremental value according to the current range.

    So, if the value of the control is 2000.6000 to change it to 1000 stage, if it is less than 2000 but more than 200 - at the stage of 100 etc.

    The following code works if I change the value of the control with SIMPLE mouse clicks. But if I just press the left mouse button and hold it down, it does not work!

    Debugging of the shows, he correctly process events and passes to the attribute to (both) control. But change of ATTR_INCR_VALUE seems to have no influence until I release the mouse button.

    ------------------------------------

    int CVICALLBACK SetTint (int command face, int, int event, void * callbackData, int eventData1, int eventData2)
    {
    float dIncValue = 10.0, dIncValue_temp;

    switch (event)
    {
    case EVENT_VAL_CHANGED:
    GetCtrlVal (hMainPanel, MAINP_INTTIME, &fTint);)
    If (fTint > 2000,0) dIncValue = 1000.0;
    If ((fTint<=2000.0)&&(fTint>100.0)) dIncValue = 100.0;
    If ((fTint<=200.0)&&(fTint>20.0)) dIncValue = 10.0;
    If ((fTint<=20.0)&&(fTint>= 2.0)) dIncValue = 1.0;
    If ((fTint<2.0)&&(fTint>0.2)) dIncValue = 0.1;
    If (fTint<=0.2) dincvalue="">

    SetCtrlAttribute (hMainPanel, MAINP_INTTIME, ATTR_INCR_VALUE, dIncValue);
    break...

    -------------------------------------

    Addition of events such as

    case EVENT_COMMIT:
    case EVENT_LEFT_CLICK:
    case EVENT_VAL_CHANGED:
    GetCtrlVal (hMainPanel, MAINP_INTTIME, &fTint);...)

    does not help.

    Swallowing of events after the setting of the attribute as

    SetCtrlAttribute (hMainPanel, MAINP_INTTIME, ATTR_INCR_VALUE, dIncValue);
    Return 1;

    does not help.

    Things like-

    ProcessDrawEvents();
    ProcessSystemEvents();

    does not help also.

    Any other suggestions? :/

    Hello

    Joint an example very smal how you can achieve this

    Best regards, Fabian

  • the event of an event queue display?

    I'm looking for a way to post an event in the event queue.

    I found the QueueUserEvent() function but seems only works in conjunction with GetUserEvent(). I don't want an another queue, I want to put the event in the queue as well as all of the user interface. is there a way to do this?

    Maybe someone knows a way to trigger the EVENT_COMMIT or the EVENT_VAL_CHANGED of a chain control after changing the value of the control programmatically?

    You can use CallCtrlCallback () immediately after programmatic change of the value of the control. If the immediate convening of this function within the same routine, which updates the control is not correct, you can define a special function for Update call with (PostDeferredCall), which is executed after the call to the function ends.

    (Well, really we could simply call the recall of control by passing appropriate values: it's a bit rough but not forbidden.) CallCtrlCallback retains the chaining of reminder of the control, in case you used)

  • scrool mouse wheel events

    Hello!

    I noticed that in CVI 9.0 when using a control slide (hot mode) with the wheel of the mouse, the only event generated is EVENT_MOUSE_WHEEL_SCROLL.

    But in 2013 CVI the same control generates EVENT_MOUSE_WHEEL_SCROLL, EVENT_VAL_CHANGED, and EVENT_COMMIT.

    This behavior is correct?

    Thanks in advance.

    The reason why these events are sent 2013 CVI is because the operation mouse wheel really does not change the value of the control under CVI 2013, which happened not to 9.0. This has been implemented from a deposit of idea exchange and it has been documented in the CVI 2013 release notes (search for "mouse wheel").

    The events are not referenced explicitly in the release notes because the essential difference is the value of the control changes. Once that happens, then, as Wolfgang mentioned, events must be sent.

    Luis

  • binary passage replaces the State after commits

    I have a binary switch unique control of four similar processes.  I use an EVENT_COMMIT to trap the change in his condition.

    However, I notice that because of hardware lag on the side of the output, the State of the binary switch (off to ON) takes a long time to change.  Indeed, visually LabWindows is not updated the State of GUI control until after all the stuff that happens in his recall.

    This seems a strange behavior for me.  The help topic for the control States:

    If the binary switch mode is warm or validation, a validation event is generated when the binary switch is active and you change its status.

    That does not imply that the GUI would lead the control in another thread, while the callback is processed?

    I also tried EVENT_VAL_CHANGED, but who behaved the same way.  Is there another type of event or mode of operation I could try so that when the binary file is changed, the GUI is updated immediately and the callback is processed at the same time?  I don't want that there is some lag so that my user is trying to hit a second time the binary!

    ElectroLund ha scritto:

    That does not imply that the GUI would lead the control in another thread, while the callback is processed?

    No: the Visual representation of the control is updated at end of reminder, so if the recall is long to run, you don't see the switch state change until the treatment ends.

    You can inform the user that something is happening by using SetWatCursor (1) early reminder and SetWaitCursor (0) to end of reminder, or force an update of the UI calling ProcessDrawEvents () somewhere in your code (but if there are several GUI updates in the meantime time can slow down the recall in a moment of junk.

  • Digital button &amp; code that must run outside the switch of the event

    I have an interesting situation.  I have a command button which I activated the control via the mouse wheel of the user (thanks to great examples of code herein for one!). To do this I like, I had to put the processing part of the code outside the set event button, such that the value of the output of the control would be updated immediately.

    The only problem with this methodology which is then when the user closes the Panel and the button control is a final reminder, this block of code is executed one last time, which translates into a non fatal error "invalid control ID '.  The solution here is relevant, but is not ideal as shown above.

    My solution feels like a hack, but tell me what you think - trap on EVENT_DISCARD and back at the beginning.  Seems to work, just feels like a patch.  Here is the code:

    int CVICALLBACK KnobCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
    {
        int prevValue = 0;
        int currValue;          // current value of knob control, range = 0-100
        double currMotor = 0;
        double currMeter = 0;
        double idealMotor = 0;
        double currVoltage;
        int max, min, inc;
    
        // find the range values set in the UIR control:
        GetCtrlAttribute(panel, control, ATTR_MIN_VALUE, &min);
        GetCtrlAttribute(panel, control, ATTR_MAX_VALUE, &max);
        GetCtrlAttribute(panel, control, ATTR_INCR_VALUE, &inc);
    
        // load the current control changed value:
        GetCtrlVal(panel, control, &currValue);
    
        switch (event)
        {
            case EVENT_COMMIT:  // any control commit:
                break;
    
            case EVENT_MOUSE_WHEEL_SCROLL:
    
                switch (eventData1)
                {
                    case MOUSE_WHEEL_SCROLL_UP:
                        if (currValue < max)
                            currValue += inc;  // increment 1 step at a time, not eventData2 number of steps (Windows scroll wheel number)
                        else
                        {
                            currValue = max;    // hold at max
                            return 1;   // Swallow event to prevent from updating UIR
                        }
                        break;
    
                    case MOUSE_WHEEL_SCROLL_DOWN:
                        if (currValue > min)
                            currValue -= inc;  // decrement 1 step at a time, not eventData2 number of steps (Windows scroll wheel number)
                        else
                        {
                            currValue = min;    // hold at min
                            return 1;   // Swallow event to prevent from updating UIR
                        }
                        break;
    
                    case MOUSE_WHEEL_PAGE_UP:
                        if (currValue < max)
                            currValue += (inc * 5);  // eventData2 = 0 when PAGE up/down
                        else
                        {
                            currValue = max;    // hold at max
                            return 1;   // Swallow event to prevent from updating UIR
                        }
                        break;
    
                    case MOUSE_WHEEL_PAGE_DOWN:
                        if (currValue > min)
                            currValue -= (inc * 5);  // eventData2 = 0 when PAGE up/down
                        else
                        {
                            currValue = min;    // hold at min
                            return 1;   // Swallow event to prevent from updating UIR
                        }
                        break;
                }
                SetCtrlVal(panel, control, currValue);  // update control with processed value
                break;
    
            case EVENT_VAL_CHANGED:
                if ((currValue < prevValue) && (currValue > min))         // decrementing above floor
                {
                    currValue -= inc;
                }
                else if ((currValue > prevValue) && (currValue < max))        // incrementing below ceiling
                {
                    currValue += inc;
                }
                else if (currValue = max) // TODO: this condition doesn't work as expected; control doesn't trap for wrap-around from max to min, vice versa
                {
                    currValue = max;    // hold at max
                    return 1;   // Swallow event to prevent from updating UIR
                }
                else if (currValue = min) // TODO: this condition doesn't work as expected; control doesn't trap for wrap-around from max to min, vice versa
                {
                    currValue = min;    // hold at min
                    return 1;   // Swallow event to prevent from updating UIR
                }
                SetCtrlVal(panel, control, currValue);  // update control with processed value
                prevValue = currValue;  // update state variable
                break;
    
            case EVENT_DISCARD:
                return 0;   // TODO: bug fix for quitting cleanly, so that the code outside of the event switch doesn't execute one last time when the panel is quit.
                break;
    
        }   // end switch
    
        currVoltage =  (currValue * MOTOR_VOLT_STEP) + MOTOR_VOLT_MIN;
        currMotor = LabJackTimer(LABJACK_TIMER0);
        idealMotor = MOTOR_SLOPE * currVoltage;
    
        if (abs((int)(currMotor - idealMotor)) < MOTOR_TOL)
        {
            SetCtrlVal(panel, MAINPANEL_TEXTMSG6, "GOOD");
            SetCtrlAttribute(panel, MAINPANEL_TEXTMSG6, ATTR_TEXT_BGCOLOR, VAL_GREEN);
        }
        else
        {
            SetCtrlVal(panel,MAINPANEL_TEXTMSG6,"FAIL");
            SetCtrlAttribute(panel, MAINPANEL_TEXTMSG6, ATTR_TEXT_BGCOLOR, VAL_RED);
        }
        return 0;
    }
    

    I suggest to put the code SetCtrlVal fragment in a separate function and call this function for the correct event only; at present, it is called for any event, including the event throwing...

    In addition, there is no need to recall the values min/max/inc of your control each time, once the start programme should be enough

  • Reminders of two controls "at the time"

    I need a little help with most of the user interface callbacks and threads.

    Here's the scenario: there are two controls

    1. digital control with callback for EVENT_VAL_CHANGED

    2. button with callback for EVENT_COMMIT

    RunUserInterface() is called once at the beginning of the program. The user enters a value in the control digital with the keyboard (some numbers), and then they click on the button.

    This triggers the following events:

    (Digital) EVENT_VAL_CHANGED--> digital reminder works

    EVENT_COMMIT (digital)

    EVENT_LEFT_CLICK (button)

    EVENT_LEFT_CLICK_UP (button)

    EVENT_COMMIT (button)--> button callback runs

    EVENT_LOST_FOCUS (numeric (?))

    EVENT_GOT_FOCUS (button)

    The recall button parts can run before the digital Encore ends?

    Thank you!

    To answer question of Ian, Yes, all UI events are sent to the thread that owns the group. Here's the relevant help topic of the CVI.

    Luis

  • CVI executable causes an on update of Windows 10 anniversary 0xC0000005 Access Violation.

    Created executables always causes an Access Violation (0xc0000005 exception) to the closing period on Windows 10 RS1 (update of the anniversary).

    This problem occurs in LabWindows CVI 2015 and 2015 SP1.

    How to reproduce: simple program to create and compile with the (x 86) release profile by default.

    for example:

    #include "test.h".

    int ph;

    int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpszCmdLine, int nCmdShow)
    {
    If (InitCVIRTE (hInstance, 0, 0) == 0)
    Returns - 1; / * memory * /.

    pH = LoadPanel (0, "test.uir", group of EXPERTS);
    DisplayPanel (ph);
    RunUserInterface();

    return 0;
    }

    int CVICALLBACK CallExit (int, int int event, control panel,
    void * callbackData, int eventData1, int eventData2)
    {
    switch (event)
    {
    case EVENT_COMMIT:
    QuitUserInterface (0);
    break;
    }
    return 0;
    }

    The problem is visible on the control panel > reliability history > Error Reporting:

    Also the code of the executable file (exit code) is always 0xc0000005 instead of zero.

    To check out more easily code can be called the executable through file .bat:

    off @echo
    Test.exe
    echo ExitCode = %ERRORLEVEL%
    pause

    I have observed that if multiple instances of the same program are running, only block when the last instance is closed. It seems that the problem occurs at the time that the CVI runtime is released from the ram. (The latter is only a guess)

    Hello

    We did some research and saw that the failure is related to some police files in

    c:\Windows\SysWOW64\cvirte\fonts

    c:\Windows\System32\cvirte\fonts

    Could you try deleting these files and see if the heater is always performed. If this isn't the case, it would be a work around if you do not use these fonts.

    We continue the investigation to see the exact cause

  • Question of Panel throw

    Hello

    When I close my program (QUIT button LabWindows) I thought that with the line "DiscardPanel (MainPanelHandle)"; the program is closed and the application is not running. But now I have seen that after this call every button I have in my application gets called and closed with the return 0. Can someone explain why I have this and if this is normal? Each button of my application works with the event "EVENT_COMMIT".

    Hope someone can help me.

    Best regards

    When you throw a Panel, each control (not only the buttons) receives an EVENT_DISCARD event: this is intended as a way for you to manage a gap of Panel where it is necessary to manage some special actions. For example, when it receives an event to a button that controls an external device could issue an order to stop at this device.

    Your checks should not receive any event EVENT_COMMIT: reminders that only manage this event should get called and immediately exit without doing anything: you can check this by placing a breakpoint in a reminder and step-track its behavior (F8 after break issues instructions one by one so that you can monitor exactly what happens).

  • Reminders of understanding

    I've been with CVI programming since the days of BASE in the 1990s, went to C-base code but have always programmed of up and down and never used reminders much. I want to change that. So here I am with my first serious attempt and something is not just make sense.

    I have a child Panel (SetupPanel as a handle) with a hot digital control. I want the user to be able to type a number and press ENTER to enter the value and return to the main loop. I know recall events are generated with the entry number, so I have an if statement to get the value of control when he sees a VAL_ENTER_VKEY event. The code runs correctly, but the new value the user has entered into the digital control is not being caught and stored in the variable referenced after executing the GetCtrlAttribute function successfully (returns a 0 indicates success).

    The GetCtrlAttribute same function with the same variables works very well elsewhere in the code, when it is called, it is only in the block of reminder where it is not catch the value of the current digital control. It has to be something fundamental, I do not understand about the use of reminders.

    int MaxDSCallback (int command face, int, int event, void * callbackData, int eventData1, int eventData2)
    {
    If (eventData1 == VAL_ENTER_VKEY) {}
    RET = GetCtrlAttribute (SetupPanel, Setup_AxisMax, ATTR_CTRL_VAL, &ddum);)
    }
    Return (0);
    } / / MaxDSCallback

    After execution, ret = 0, but the value of ddum is what it was before that the user has replaced the control, not the value of newly. Tried a ProcessSystemEvents() after the GetCtrlAttribute, no joy.

    Can someone explain to me what is happening here?

    Now, I am even more confused... Have you tried the following:

    int MaxDSCallback (int command face, int, int event, void * callbackData, int eventData1, int eventData2)
    {
    If (event == EVENT_VAL_CHANGED) {}
    RET = GetCtrlAttribute (SetupPanel, Setup_AxisMax, ATTR_CTRL_VAL, ddum &);)
    }
    Return (0);
    }

    This should return only after you press the Enter key, not after each keystroke...

  • Diag on flax (with Diagnostic command set auto toolkit)

    Hello

    I need to develop an application in Labwindows/CVI 2013 which can make diagnostic tests based on LIN. I installed the resource kit "Automotive Diagnostic Command Set" and even tried the 2 examples of NEITHER.

    I have a baord PXI-8516. I just need to send and receive frames.

    I know that this framework is a good example: 3C-92-F2-00-00-00-00-00-00

    The problem with the example, it's that the 0x3C and 0x3D are not used. I need to know how to create and send a frame and how to receive the ansewer (it takes a few ms before reading?)

    here my code (part on the callaback function):

    	unsigned char dataIn [8] = {146, 242, 0, 0, 0, 0, 0, 0}; HEX: 92, F2, 00, 00, 00, 00, 00, 00
    unsigned int len = 8;

    switch (event)
    {
    case EVENT_COMMIT:

    Delay (1);

    for (int i = 0; i)<>
    {
    status = ndUDSWriteDataByIdentifier (& DiagStruct, 0x3C, dataIn, len, & success);

    Delay (1);
    status = ndUDSWriteDataByIdentifier (& DiagStruct, 0x3D, dataIn, len, & success);
    Delay (1);
    }

    Thank you in advance!


  • Response to a change in a numeric field

    Hello

    I have a question about the digital field. I have the following problem. I have two numeric fields. I am writing a value in a field. Now, a calcualtion gives me a new value with the old value. I would like to print the new value in the second field of nummeric.

    So my problem is this.

    The main program starts when I press a start button. So what I would like to have is the new value printed without pressing the Start button. Basically, I would like to see the solution before starting the program. I enter a value and see the solution, now the solution is not correct, so I change the value and see the new solution. This solution is correct and I start the program. It's save calculation time. Can I change the value and at the same time, according to me, if it is correct to start with the value. (example: first of all the ground 1000 Hz, second field (T = 1/f) 0.01 s).

    I hope you understand what I mean and can someone help me?

    Best regards

    This happens install a callback function in numerical order and the EVENT_COMMIT event management (assuming that the control is left in HOT mode as the default value).

    From the probgram, whatever that means, will be by the callback of a command START button function

  • GetCtrlVal problem

    Hello

    I have a problem with GetCtrlVal. Wenn I start my application and Quit it I get this error message: NOT FATAL RUN - TIME ERROR: "Test.c", line 206, col 5, id thread 0x00001A4C: GetCtrlVal function: (return value ==-13 [0xfffffff3]). Invalid control ID.
    I checked the ID of the control, and there should be no problem with him. I have this problem when I run my writing also requires certain values and after finished applications and I would like to exit the application with the standard quite setting.
    Double Amplitude = 0, the duty cycle = 0;
    int Mode = 0, samples = 0, SampleRate = 0;

    GetCtrlVal (Panel, Panel_TREE, &Mode);)
    GetCtrlVal (Panel, Panel_Amplitude, & Amplitude);
    GetCtrlVal (Panel, Panel_SampleRate, & SampleRate);
    GetCtrlVal (Panel, Panel_Samples, & samples);
    GetCtrlVal (Panel, Panel_DutyCycle, & of the cyclical report);
     
    switch (event)
    {
    case EVENT_COMMIT:
    Switch (mode)

    ........

    Best Ragards

    Have you tried to move all GetCtrlVal inside the EVENT_COMMIT clause?

    You say that you have the problem at the end of the program: in this case, the event is probably EVENT_DISCARD, which is sent to all controls and panels in the application; at some point you can access a control that has already been deleted from the memory. These GetCtrlVal statements are executed for * ALL * received events from the control, even in every movement of the mouse: it is a usage of unnnecessary resources that can put you in unwanted situations.

  • Tree control mode: Returns a validation event when the NORMAL value

    CVI 2013: I am writing a software to change the command tree modes based on the user's selection. I noticed that when the command is set to NORMAL, I got a "EVENT_COMMIT". Just for reference, I am using a custom control - group of Radio buttons, but the bug (I'm assuming that) is in the tree control are I forgot something?

    An application of Corrective Action (CAR) has been filed for this behavior. His number is 578618. You can monitor the condition of this CAR by checking the notes Readme or release new versions and checking the bug fixes section.

  • People with disabilities control operated even if disabled

    I just encountered a small problem which seems a bug to me.

    If you have a Panel and a knob under the close control, you can close the cover with the Red Cross in the corner, even if the button is disabled!

    It seems to me that in this case the Panel must not be closed instead.

    Attached to a small project that reproduces the situation: run the project, press "Disable exit button", click the x in the top right corner and voila: the Panel closes!

    Tested up to CVI2013SP2

    In the absence of other comments, I post here the solution to this problem, which is quite simple: the recall of control should be amended as follows:

    int CVICALLBACK QuitCallback (int, int int event, control panel,
    void * callbackData, int eventData1, int eventData2)
    {
    int grayed out;

    If (event! = EVENT_COMMIT) return 0;

    GetCtrlAttribute (Panel, control, ATTR_DIMMED, & gray); Test the control state
    If (! grayed) QuitUserInterface (0); Terminate the program only if possible

    return 0;
    }

    This seems a serious mistake for me, for this reason I posted a product suggestion: don't hesitate to support him with congratulations if you second in my opinion.

Maybe you are looking for