on the timing and the GUI control loop

Hi all

I have a code with two buttons placed on the Panel, one is EXECUTED, another is STOP. Initially, STOP is disabled and when I launch RUN, the JUDGMENT will turn off. But when the JUDGMENT is made, the RACE will be activated.

#include "testimg.h"

#include 
#include 
#include "asynctmr.h"
#include 
#include 
#include 
#include 
#include "toolbox.h"

static int panelHandle = 0;

static int stoprun = 0;

int main (int argc, char *argv[])
{
    int error = 0;

    nullChk (InitCVIRTE (0, argv, 0));
    errChk (panelHandle = LoadPanel (0, "testimg.uir", PANEL));

    SetCtrlAttribute(PANEL, PANEL_STOPBUTTON, ATTR_DIMMED, TRUE);

    errChk (DisplayPanel (panelHandle));
    errChk (RunUserInterface ());
Error:
    if (panelHandle > 0) DiscardPanel (panelHandle);
    return 0;
}

int CVICALLBACK MainPanelResponse(int panel, int event, void *callbackData, int eventData1, int eventData2)
{
  if (event == EVENT_CLOSE) QuitUserInterface (0);
  return 0;
}

int CVICALLBACK RunButtonResponse (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
  if (event==EVENT_COMMIT)
  {
    int N=20;

    stoprun = 0;
    SetCtrlAttribute(panel, PANEL_STOPBUTTON, ATTR_DIMMED, FALSE);
    SetCtrlAttribute(panel, PANEL_RUNBUTTON, ATTR_DIMMED, TRUE);
    for (int i=0; i0) break;
    }
    SetCtrlAttribute(panel, PANEL_STOPBUTTON, ATTR_DIMMED, TRUE);
    SetCtrlAttribute(panel, PANEL_RUNBUTTON, ATTR_DIMMED, FALSE);
  }

  return 0;
}

int CVICALLBACK StopButtonResponse (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
  if (event==EVENT_COMMIT)
  {
    stoprun = 1;
  }
  return 0;
}

My code is a repeat for N times, once the START button is kicked. And if the STOP button is started until the task has finished running. Stop the current application and returns the value false. I wrote the code, but it seems does not work. It seems that the application cannot be interrupted before the file for the task. I don't know what's wrong with my code. If you have any experienence with this, could you please tell me what is the problem with my cdoe? Thank you.

What you see is the expected behavior: in your loop inside the run key, you have a 5 second wait in which the system is frozen, then another 2 sec with the system frozen again. For the simulation need, you must change the code this way:

double tini;

tini = Timer ();requestToStop = 0;
while (Timer () - tini < 5.0 || requestToStop) {
  ProcessSystemEvents ();
  sleep (50);
}

The stop button then must trigger a global variable that stops the loop (requestToStop in my example above).

In actual code, such a long-term process should not be handled within a control reminder: you will need to place it elsewhere depending on how you want to structure your code in order to let the user interface responsive. Available alternatives are:

-A reminder of timer UI

-A reminder asynchronous timer (similar to the preceding but executed in a separate thread)

-A separate thread issued with CmtScheduleThreadPoolFunction

If this date is the solution, the stop button must be manipulated inside the code by triggering a signal enabling the treatment stop securely.

Tags: NI Software

Similar Questions

  • Error 200077 (frequency) and 200452 (task control loop) error occurred DAQmx create calendar Source.vi

    Hello

    I'm trying to control the timing of a timed loop. So far, I have tried several approaches via the software and which worked very well except the time loop in some missed cases 1-2 Ms I want to make sure the timing is right. I tried to provide an external clock through the acquisition of data I. The system I use is NI USB-6212. It has two counters and DIO and AIO, but I keep getting errors. I tried two different approaches. One was to use directly the game 'DAQmx create calendar Source.vi' in frequency mode, and when I did, I got error 200077. Then I found a post of somone saying that sometimes it is not possible and an alternative method is to use the same vi but set task of loop control mode. This one gave me Error200452. For this one you will see in my attachment the suggestion was to use an AI then the moment of him and then use this task for Creat DAQmx synchronization Source.

    I don't know what the problem is or if I need to put something differently.

    Please let me know if you can help me with this.

    I'll try to continue to work on that, but if anyone of you a suggestion I'll be very happy to consider the issue.

    Thank you in advance,

    Best, Massimo.

    Massimo,

    In my view, the errors that you see are the result of your hardware USB-6212 is supporting the functionality of the task control loop.  I have a M Series PCI card that is capable of operating both of your screws attached without problem (although they still +/-1ms variation on occaision).  When I try to use a USB-6212 simulation, I get the same error codes that you do.  Unfortunately, it's just a case of a lack of equipment.

    Kind regards

  • How can I get the Char String ring from the GUI Control Label

    Recalling the ring control text label of a ring of GUI control, not the control Label, but the label of the indexed by pairs value.

    GetLabelFromIndex is located in the index help online, and you can also find it in the Search tab. I don't know if that's what you hear.
    If what you mean is to ask how you would be able to find it if you have not already know his name, then I agree that just by typing keywords in the "search" tab is probably not the best idea. What could have done is to go to the section of the table of contents that lists all of the functions to be used with the list control, and then, look at what is there until I found what I needed. You don't even need to use the online help. You can use the library feature tree (UI library > graphics/controls/bands charts > list/tree controls (value/label)). Or better yet, just start with a function with that you know works
    trees and then look at the features around it.

    Luis
    NEITHER

  • loop of two producers for quick DAQmx and the user controls?

    Hello

    Sorry if my question is maybe a bit too general (I don't have a VI implementation yet).

    I think about the solutions for a Structure of producer-consumer with event loop in the part of the producer.

    So far, if I had to do a project with DAQ, data analysis, data recording and enter the user controls, I've followed usually this kind of approach:

    I used the producer part to capture interactions with the user, and I also had a state machine in the part of the producer, with registry change. I also buy (any faster then 10ms) DAQmx device data in the part of the timeout of the structure of the event in the loop of the producer. I have several consumer loops down, such as data analysis, data recording, etc... I send the data measured in a cluster with the enumerations of the State of the loop from producer to consumer with queue loop.

    I'm not happy with my approach for the following reasons:

    1,

    If I need device acqure faster DAQmx data that the operating system clock can handle (like 1 MHz), so I can't put it in the part of time out of the structure of the event of the producer loop, because here I can go through the while loop with minimum 1 ms.

    2,

    If I put this part DAQ in a loop for quick consumption, it is not admissible for orders from the QUEUE line after that it starts to run (assuming that I use the standard structure of producer-consumer, so consumer loop every time iterates once, when a package comes from the Dequeue).

    Then say, how can I control a young (timed by DAQmx device internal clock) loop of data acquisition of the structure of the producer of the event loop? As loop DAQ to start, stop, restart, etc...

    Thank you very much for the advice!

    You can certainly have several loops of producer.  Have a User Interface, loop driven events to send commands and a separate data acquisition loop to send data are not a problem.  Each loop has a separate queue. (You might be able to make it work with a single, but using two queues avoids many problems).  Often, I used a system of three loops long before that everyone was talking about calling it a producer/consumer.

    Lynn

  • control design and simulation in a loop the final amount not what I expected

    Hi the LabVIEW forum members.

    I have a frame control and Simulation in which I am simulating a regulator in closed loop (see file attachment).  When I apply a step of the input unit that I expected to get the answer to deposit at the unit, i.e. the stage of entry being the set point.  However, he moved to about 0.625.

    Can someone point me in the right direction please?  I'm obviously doing something wrong here.

    Kind regards

    OK guys,

    Cancel my last post, I found my mistake, it was the P + I control shape, I made a mistake in the Integral control action transfer function where the Integrator not arrive to integrate an error.

    Kind regards

  • What are the Causes of 'loop Hang"problem with file i/o when using timed multiple loops on one OR cRIO-9012?

    Normal 0 false false false fr X-NONE X-NONE / * Style Definitions * / table. MsoNormalTable {mso-style-name : « Table Normal » ; mso-tstyle-rowband-taille : 0 ; mso-tstyle-colband-taille : 0 ; mso-style-noshow:yes ; mso-style-priorité : 99 ; mso-style-qformat:yes ; mso-style-parent : » « ;" mso-rembourrage-alt : 0 à 5.4pt 0 à 5.4pt ; mso-para-marge-top : 0 ; mso-para-marge-droit : 0 ; mso-para-marge-bas : 10.0pt ; mso-para-marge-left : 0 ; ligne-hauteur : 115 % ; mso-pagination : widow-orphelin ; police-taille : 11.0pt ; famille de police : « Calibri », « sans-serif » ; mso-ascii-font-family : Calibri ; mso-ascii-theme-font : minor-latin ; mso-hansi-font-family : Calibri ; mso-hansi-theme-font : minor-latin ;}

    I experienced a problem with an application. I think I've isolated the problem in the "Timed loop question - Source Code.zip" attached source code. A detailed list of my results are in the attached document "Timed loop detailed question - Results.docx.

    Overview - it seems to be closely related to the IO files and the use of "Timed loops" on the OR cRIO-9012

    1. If I activate the e/s in two loops, then two loops crash simultaneously

    2. If I activate only the e/s in a loop, then only this loop crashes

    3. If I activate the e/s in two loops and make a 'While' loop earrings, then it don't crash

    4. If it is wrote nothing in the file I/o, then it don't crash

    5. If the reference to the file is left open instead of opening and closing on each call, so it don't crash

    6. If I try to run it on "My Computer", then it don't crash

    7. If the IO is only activated in a loop and programmed to wait for one second between the file access, then it always crashes

    In my real application, any given row is only writing (at least) once a minute, but I couldn't still my application to plant within a period of 24 hours by writing a single error of a single loop once per minute, with a low CPU use. It was the impulse to test the seventh point above.

    It seems that the best solution was to open the reference to the file and let it open. I think it is a good practice in general and I'll do the update in the application. This should solve the problem, but it is very difficult to verify this due to the sporadic nature of the question. As such, I'd like to understand what was causing the problem so I can verify that it was fixed. So far, my attempts to create a single, coherent theory able to explain all aspects of this issue have failed.

    I just wanted to know at all that there has been a request for corrective action (CAR #214156) has filed for this issue to be fixed in a future release. This seems to be a problem with the VxWorks operating system, we use in real time. We have additional cRIO chassis which have a Pharlap OS where it does not work. For now, you can search for this CAR ID notes to see if this problem has been resolved for publication in the future.

    Currently, there are two solutions, we have identified for this problem:

    1. open the file before the loop and close it after. (recommended)
    2 perform file i/o in a normal loop and transfer data to a queue.

  • How to properly temporarily disable all channels except one in the multichannel PID control loop?

    Hi all

    Help me please to solve the problem. How to correctly temporarily disable/enable all channels except one in the multichannel PID control loop?

    Thanks in advance,

    Oleg

    Hi Oleg,

    the entry "Car?" of the AdvancedPID is a table – as well as MS and pv entries.

    So what's the problem say - / allowing for a control (aka of entry) instead of all loop?

  • the audio control panel does not appear on various websites which I am sure they are there. I see them in IE and chrome, but not in FF

    The audio control panel does not show simply. On this site, I should see the control panel. http://www.testplek.annemariebeeke.nl/huiswerkopdracht_week3_bonus.html.
    It does not show in the other browsers, other people can see it, but I can't.
    Even with these sites:
    http://www.jokevan.nl/HTML5/oef3-3.html
    http://kokenvoorpapegaaien.nl/Kellerhuis/oef3-3.html

    Reload Web pages, and ignore the cache.

    • Hold SHIFT and click reload.
    • Press 'Ctrl + F5' or 'Ctrl + Shift + R' (Windows, Linux)
    • Press 'Cmd + Shift + R' (MAC)

    Clear the cache and cookies from sites that cause problems.

    "Clear the Cache":

    • Tools > Options > advanced > network > storage (Cache) offline: 'clear now '.

    'Delete Cookies' sites causing problems:

    • Tools > Options > privacy > Cookies: "show the Cookies".

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox/tools > Modules > appearance/themes).

  • the volume control is grayed on and no sound

    I use a Mac Pro, purchased in mid-2010, with a 2.8 GHz Quad-Core Intel Xeon Processor, 13 GB 1066 MHz DDR3 ECC memory, which I've recently updated to El Capitan version 10.11.4.

    I had a few glitches to mail to work but got there. Then I realized that I had no sound. The volume control is grayed and the button is at MAX, but there is no sound.

    I can't try to find where a control can be hidden which let me re - turn on the volume. Nobody knows what it takes to turn on the sound?

    Hello

    Try resetting your NVRAM memory.

  • How can we separate "Icons and text" of the browser control buttons (back, forward, etc.) since the icons on the toolbar of the add-on?

    With us, it is not a problem. I don't know why it's different here at work - even editing, same settings (as far as I know).
    Windows Vista
    Firefox 7.0.1
    Status 4 Evar installed to activate the add-on bar in a status bar

    I have a NoScript module icon in the corner, which works very well. If I add a GreaseMonkey icon in the menu customize, "Icon and the text" is displayed for this icon as the icon and text browser controls (home, stop, etc.). Other icons the module show icon and the text (S4E, for example). NoScript is the only one I've found so far that collapses down to just an icon.

    I like this leads to the bar having a higher status (add-on). Basically what I want is for only the icon is displayed in the State (toolbar Add on), while keeping icons and text in the browser controls. My current solution is simply to remove the other icons of the add-on - it from the status bar (add-on), but which removes the ease of turning on/off and setting options.

    Please tell me if I can provide you with another thing and thanks for your help.

    Edit: I have some screenshots to show what I mean.
    desired behavior
    problem when the icon is added

    I tried, and while it does not remove the text, buttons retain their width, collapses don't not down icons. I was able to get exactly the effect I want to by changing the setting in the DOM, as stated in my post above, but which only lasted as long as the session and returned to the way it was before, when I restarted Firefox.

    After a few tries, I finally joined the userChrome following tweaks. This tweak sets the buttons didn't use any text, be limited to 20 pixels of width, and, if a drop-down list arrow is present, to hide that. Greasemonkey uses a drop-down list item separated so it must be hidden specifically.

    #addon-bar .toolbarbutton-text { display:none !important; }
    /*The following work for most of my icons except Greasemonkey*/
    #addon-bar .toolbarbutton-menu-dropmarker { display: none !important; }
    #addon-bar .toolbarbutton-1 { min-width:20px !important; }
    /*The following are specific to greasemonkey*/
    #addon-bar .toolbarbutton-menubutton-button { min-width:20px !important; }
    #greasemonkey-tbb > dropmarker {  display: none !important; }
    
  • HP 5510 will be not printed black before and after you installed the new cartridge. the specified controls did.

    Photosmart HP 5510 will be not printed black before and after you installed the new cartridge.  The specified controls did.

    Yes, I was referring to manually clean the print head. I see that the 5510 lacks the possibility of leaving the print head manually.

    You can click on the menu of your SETUP program on your screen and go to TOOLS and clean the print head from there.

    If this does not resolve your problem, you may need to replace the print head.
    Contact HP Total Care (1800-474-6836), and if your unit is under warranty, its free.

    Let me know if this can help, thank you.

  • The output on my Macbook Pro is not giving me the drop-down list, &amp; happens either in the port of the helmet or digital port and neither one is what I need. I tried turning off the computer and hold "Shift"' Control', 'Option' with the power-o ".

    The output on the sound output box has no drop downs. The audio output suddenly disappeared and when I went to the 'exit' sound in 'sound preferences' the only thing that would show was the headphones.  After that I tried a couple of things suggest that 'Helping Apple', sometimes in digital form & everything that happens you can't change for something else.  Things I've tried suggested by Apple press help were the "Shift control option buttons & button / stop at the same time."  or press the Option, the command, the P & R key as soon as possible after you have pressed the button On.  Hold down until after the second gong during a manoeuvre.   This did cause the digital option, but none of these 2 is the one I need.  Help

    Perhaps, it would be useful to know what that is exactly the one you need. Are get you an external speaker output or anything like that. Also, it would be useful to know the operating system you are using.

  • Fingerprints and the remote control supported on Satellite P100-387

    P100-387 has a fingerprint and the remote? Please, someone answer me.
    Thank you.

    Hello

    To my knowledge, the Satellite P100-387 does not support the fingerprint reader and is not supplied with the remote control.
    But you're right.
    The fingerprints and the remote control are optional and some laptops in the P100 series support fingerprint reader and are delivered with command remotely.

    I also found this site with P100-387 material specifications:
    http://EU.computers.Toshiba-Europe.com/cgi-bin/ToshibaCSG/JSP/productPage.do?service=EU&PRODUCT_ID=120514#0

  • I set up the new user on my MacBook Pro with the parental control, and I want to allow access to Word, Excel, PowerPoint for Mac.  I have those checked in the dialog box list, but they may not appear in its applications. Am I missing something?

    I set up a 'user' for my son and use parental controls.  I want to him to have access to Word for Mac, and it appears in the list of applications I can check to allow use for.  However, when we opened a session under his username, these applications do not seem to be anywhere.  When you configure new users, applications such as Word for Mac or the available Pages on users?  I can't find any information to help in this regard.  I don't know if I'm missing something under user put up, or parental controls, or both.  Any help would be greatly appreciated!

    These requests should be made available, provided you installed then in the folder/applications, not in a private folder ~/Applications for a specific user.

  • Create a journal in the tab control tab and create tab is disabled and grayed out

    Hello

    Can you helpme to solve my question about the connection in the tab control? So basically I have two pages in a tab control, page 1 contains, log in as user name, password, and login button and second page is nothing. After the user has entered the correct user name and password in the form of a string, page 1 will be disabled and grayed out and automatically will be on page 2? I also download the vi that I created and please correct me if I have a problem with my vi.

    Please help me with this ASAP, because I have assignment based on the view of any customer lab server.

    Thank you


Maybe you are looking for