Would you Open and Close DAQmx tasks within a function or Globally

Hi Guys,
This should start something.
The subject is DAQmx Tasks.
If you were writing a function that is called many times, say MeasureVolts (double *Value) to obtain a reading from an Analogue Input Channel.
Would you.
1. open and start the task inside the function, do the measurement and then close the task inside the same function.
or
2. open the task globally and later do the measurement inside the function using the global task then close the task only when the application is closed.
I am mostly concerned with the overhead of task generation and closing, what do you guys and girls out there do?? and what is the general opinion?
I would appreciate your views.
Regards
Paul.

I would definitely NOT keep configuring and clearing (I think that's what you mean by open and close) the same task over and over.  I would configure once, read many times in my main app, then stop & clear once.
I typically like to package such data acq into an "Action Engine" that keeps track of its own DAQmx task id so I don't need to sling that task id wire around into multiple parallel loops / vi's.  Attached is a very stripped-down example for Digital Input. 
I would typically do more with error testing and would make the "Action" enum into a typedef custom control, but this gives you the basic idea.  The action engine approach works very nicely when there's a small # of different kinds of input parameters and output info needed to support all the necessary action cases.   When you start needing a large number of differnent kinds of inputs and outputs to support the desired actions, then you start having difficulty with (1) having enough terminals to wire and (2) remembering which inputs and outputs are meaningful for which actions.
-Kevin P.
Attachments:
DI Action Engine.vi ‏75 KB

Similar Messages

  • How do I open and close VIs from within a VI?

    Ladies and gentlemen,
    I would like to use a VI to open and close other VIs based on user input.  Example:  The first VI will have text that reads:  "Does the car have heated mirrors?"  There will be two buttons: one for "YES" and the other for "NO."
    If the user hits the "NO" button, the current VI will close and a similar VI will open that asks the user the next question, "Are the mirrors lighted?" "YES" or "NO..."
    If the user hits the "YES" button, the current VI will close and another will open that will tell the user to "Activate the heated mirrors" and press a button that will say "NEXT."  At that point, that VI will close, and in two minutes another VI will open and ask the user "Is the driver's side mirror hot?" with another set of "Yes" or "No" buttons.  If the user presses "YES" we will have verified that the heated driver's side mirror is working properly and store that information somewhere .  If the user presses "NO", the VI will close and another VI will open with some kind of repair instruction and a button that says "RETEST" that will rerun the heated mirror test when repairs are completed.
    During the two minutes we are waiting for the mirrors to heat up the program should move on to the next question: "Are the mirrors lighted?" "YES" or "NO..."
    Does anyone know how to manipulate VIs in this way?  Please help!
    Drew

    Instead of opening and closing vi's, just create one main vi with a state machine architecture.  Search for examples on state machines to get a basic understanding of them.  This is pretty complex so I have written an example of how this could be accomplished.  The trick part was the 2 minute timer (my vi is set for 5 seconds for quick testing).  Each state produces a question, and depending on the answer, the next state is inserted into a queue.  You can add more states for more questions and answers.  Notice that the boolean buttons can be hidden if you just want to show one button (like Next) instead of two buttons (Yes and No).  Study the vi and let me know if you have questions.
    - tbob
    Inventor of the WORM Global
    Attachments:
    Q&A.vi ‏166 KB

  • Why would Siri open and close randomly?

    My iPhone 5 displays the oddest and most erratic behavior and I cannot figure out why!  Hopefully someone here can head me in the right direction!
    A few times a week, Siri will pop up with her "What can I help you with" window.  I'll close it and it will reopen again.  Sometimes it even causes other apps to open.  Open and close.  Over and over.  It happens randomly or at least I cannot see the common denominator anyway.   I use a bumper with my phone but it does not cover or even touch the screen button.  
    Any ideas?
    Thanks for the help!
    Peter

    It is possible that you are pressing the home button while the phone is in your pocket. If this is not the case then plug your phone into your computer and use iTunes to restore your phone. Also restore as a new iPhone not from backup.

  • Firefox closes existing window when you open and close a new window

    When I'm using firefox and need to open a new window (or a website opens a new window) and I'm done with that new window and close it, Firefox attempts to also close the previous window that I am using. I've tried reinstalling, but other than that I don't know what to do. What usually happens when I close the window is that I have multiple tabs open in the other one and it asks me if I would like to close all my tabs. When I hit cancel, it asks me again. Once I hit cancel the second time it stops bothering me.

    I thought it was doing that also. But I found that if I start a new chat with someone I was messaging before, then the old messages re-appear in the messages window.

  • Is it god for the computer if you open and close it every 5 mins or less

    becuase im scared of burning my computers hardware and etc in their helpp
    plzz

    Not really. Constantly opening and closing the lid can affect the hinges not to mention some strain on the electronics. You won't burn it out, but you can somewhat reduce its life expectancy.

  • How to open and close files from UIwindow my function doesn't work

    Hello guys!
    I am trying to create a simple ui-interface.
    I made one button so far.
    but my function does not work.
    if I run the function without dialog box it works perfectly!
    when I running the function in the dialog window, picking a file and open, nothing happens why?
    please help me with a correct code.
    also how do I write  2 functions that also closing a file and  saving a file?
    here is my simple code.
    var w = new Window ("dialog");
    button.onClick = function () {
    OpenMyFile();
    w.show ();
    function OpenMyFile(){
    var myFile = File.openDialog();
    app.open(myFile)
    Thank you in advance.

    Well, to answer your first question, you've added an event listener, but you haven't actually added the button itself.
    try this:
    var w = new Window ("dialog");
    b = w.add("button", undefined, "Click me!");
    b.onClick = function () {
    OpenMyFile();
    w.show ();
    function OpenMyFile(){
    var myFile = File.openDialog();
    app.open(myFile)

  • Is there a remote app that will let me open and close programs on my iMac

    Hi There,
    I know that I can use the Apple Inc "Remote App" to control my iTunes on my iMac - and I really like it for when I am not right at my computer, but I have to have iTunes open on my iMac before I can use it which is a bit of a pain to have to think "Am I going to use iTunes today?" or to run off to my office at the other end of my house when I decide I want music through my speakers and so my question is thus.
    Is there a remote app that I can download for iPhone or even iPad lets you open and close programs on your iMac when you are not actually sitting at it. So say I want to open iTunes on my iMac i would do the following
    1: Open the remote app on my device (either iPhone or iPad)
    2: See a representation of iMac screen on that device (cut down for iPhone)
    3: Chose the program I want (iTunes in this case) and it will open on my iMac allowing me to begin using the program remotely on my remote device.
    I am not talking about remote desktop or anything here (I don't want to do complicated things on it) just be able to open programs like iTunes so I can have the music play through my home speaker system without having to have all of my programs already running on my mac incase I decide to use them
    Message was edited by: Jason G Telford: Posted the question accidentally so I had to edit it with the right title

    this question has just been marked as answered to clear it from the unresolved questions list

  • 1 new update have been added to the project would you like to close the project and apply these updates message in project 2010

    1 new update have been added to the project would you like to close the project and apply these updates message  in project 2010.
    One of the PM is getting above message and not any recent changes happened?

    Hi,
    This message appears when an update has been sent for his approval and is pending. It could happen while opening the project plan, or when clicking on something like "retreive tasks updates" from the backstage menu of MS Project Pro.
    The PM should go to his approval center and check for any approval pending.
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • Since installing LTR 5.4, which I've now upgraded to 5.6, I've encountered repeated slowness and malfunctions in operations, especially when using the Compare View function and the Tab key to open and close the right and left side panels.  Such problems n

    Since installing LTR 5.4, which I've now upgraded to 5.6, I've encountered repeated slowness and malfunctions in operations, especially when using the Compare View function and the Tab key to open and close the right and left side panels.  Such problems never arose during two years of using LTR-4 and nothing else has changed on my computer.  I have a pretty simple system with only a few plug-ins, which are usually not in operation.  I have 12GB of RAM in my Windows 7 PC.  I could illustrate these problems with screen shots if you would tell me how to submit screen shots.  Otherwise I will try to describe the problems in words.
    The problem is clearly cumulative, growing worse as usage time passes.  Compare View feature gradually slows down and eventually seems to choke as my work session proceeds. If I Exit LTR and re-enter and start all over, things will work normally for maybe 30 minutes, but then the Compare View feature begins to become very slow to respond.   In a recent example with my screen full of thumbnails in Library mode I highlighted two images to compare. LTR started to open the Compare View screen by first having the top row of thumbnails disappear to be replaced by the "SELECT" and "CANDIDATE" words in their spaces  (but no images), but Compare View never succeeded in gaining control of the screen. After some seconds the top row of thumbnails reasserted its position and the Compare View windows disappeared. But LTR kept trying to bring them back. Again the top row of thumbnails would go away, Select and candidate would reappear, try again, and give up. This went on for at least 2-3 minutes before I tried to choose File and Exit, but even that did not initially want to respond. It doesn't like to accept other commands when it's trying to open Compare View. Finally it allowed me to exit.
    To experiment I created a new catalog of 1100 images.  After 30-40 minutes, the Compare View function began to operate very slowly. With left and right side panels visible and two thumbnails highlighted, hitting Compare View can take half a minute before the two mid-size  images open in their respective SELECT and CANDIDATE windows. When the side panels are open and two images are in the Select/Candidate spaces, hitting the Tab button to close the side panels produces a very delayed response--25-30 seconds to close them, a few more seconds to enlarge the two images to full size. To reverse the process (i.e., to recall the two side panels), hitting Tab would make the two sides of the screen go black for up to a minute, with no words visible. Eventually the info fields in the panels would open up.
    I also created a new user account and imported a folder of 160 images. After half an hour Compare View began mis-placing data.  (I have a screen shot to show this.)  CANDIDATE appears on the left side of SELECT, whereas it should be on the right. The accompanying camera exposure data appears almost entirely to the left of the mid-screen dividing line. Although the Candidate and Select headings were transposed, the image exposure data was not, but the data for the image on the right was almost entirely to the left of the line dividing the screen in two.
    Gurus in The Lightroom Forum have examined Task Manager data showing Processes running and Performance indicators and they see nothing wrong.  I could also send screen shots of this data.
    At this point, the only way I can process my images is to work 30-40 minutes and then shut down everything, exit, and re-start LTR.  This is not normal.  I hope you can find the cause, and then the solution.  If you would like to see my screen shots, tell me how to submit them.
    Ollie
    [email protected]

    Since installing LTR 5.4, which I've now upgraded to 5.6, I've encountered repeated slowness and malfunctions in operations, especially when using the Compare View function and the Tab key to open and close the right and left side panels.  Such problems never arose during two years of using LTR-4 and nothing else has changed on my computer.  I have a pretty simple system with only a few plug-ins, which are usually not in operation.  I have 12GB of RAM in my Windows 7 PC.  I could illustrate these problems with screen shots if you would tell me how to submit screen shots.  Otherwise I will try to describe the problems in words.
    The problem is clearly cumulative, growing worse as usage time passes.  Compare View feature gradually slows down and eventually seems to choke as my work session proceeds. If I Exit LTR and re-enter and start all over, things will work normally for maybe 30 minutes, but then the Compare View feature begins to become very slow to respond.   In a recent example with my screen full of thumbnails in Library mode I highlighted two images to compare. LTR started to open the Compare View screen by first having the top row of thumbnails disappear to be replaced by the "SELECT" and "CANDIDATE" words in their spaces  (but no images), but Compare View never succeeded in gaining control of the screen. After some seconds the top row of thumbnails reasserted its position and the Compare View windows disappeared. But LTR kept trying to bring them back. Again the top row of thumbnails would go away, Select and candidate would reappear, try again, and give up. This went on for at least 2-3 minutes before I tried to choose File and Exit, but even that did not initially want to respond. It doesn't like to accept other commands when it's trying to open Compare View. Finally it allowed me to exit.
    To experiment I created a new catalog of 1100 images.  After 30-40 minutes, the Compare View function began to operate very slowly. With left and right side panels visible and two thumbnails highlighted, hitting Compare View can take half a minute before the two mid-size  images open in their respective SELECT and CANDIDATE windows. When the side panels are open and two images are in the Select/Candidate spaces, hitting the Tab button to close the side panels produces a very delayed response--25-30 seconds to close them, a few more seconds to enlarge the two images to full size. To reverse the process (i.e., to recall the two side panels), hitting Tab would make the two sides of the screen go black for up to a minute, with no words visible. Eventually the info fields in the panels would open up.
    I also created a new user account and imported a folder of 160 images. After half an hour Compare View began mis-placing data.  (I have a screen shot to show this.)  CANDIDATE appears on the left side of SELECT, whereas it should be on the right. The accompanying camera exposure data appears almost entirely to the left of the mid-screen dividing line. Although the Candidate and Select headings were transposed, the image exposure data was not, but the data for the image on the right was almost entirely to the left of the line dividing the screen in two.
    Gurus in The Lightroom Forum have examined Task Manager data showing Processes running and Performance indicators and they see nothing wrong.  I could also send screen shots of this data.
    At this point, the only way I can process my images is to work 30-40 minutes and then shut down everything, exit, and re-start LTR.  This is not normal.  I hope you can find the cause, and then the solution.  If you would like to see my screen shots, tell me how to submit them.
    Ollie
    [email protected]

  • Open and close multisim contact with LabVIEW

    Can I open and close multisim contact with labview and read the receptor estatus (p.e. lamp)?
    Thanks.
    Attachments:
    Dibujo.JPG ‏13 KB

    Hi Guddan,
    I created a RFC having a query which is taking a long time to execute. So i want to close RFC connection with portals which is via java connector(JCO) before that query and open the connction again after that query.
    I guess i will need to understand your requirement a little more in detail, as i understand you have an RFC which has a query within to fetch some data and is taking a long time to do so. In the meantime you don't want to keep the connection open?
    My question would be, Is the role of this RFC to only execute the query and fetch the data or does it do something else?
    If it does other things and these are independent of the query execution, then you can span a parallel call within the RFC to execute the query and in the meantime the RFC does the other things (or vice versa) hence reducing the overall time taken.
    If the sole purpose of this RFC is to execute the query, then you will not be able(i mean to say there is no simple and direct way of doing this) to close the connection after the Query is started and re-establish the connection after its execution, for a simple reason that - how will you know if the query has completed it's execution, so that you can establish the connection back.
    Alternate solutions, make this a two way asynchronous call, 1) You invoke the RFC asynchronously and close the connection, the RFC in turn will execute the query and transfer the data to JCO via another RFC call.
    If this needs to be a synchronous call, then you will need to optimize the query to its best.
    Regards,
    Chen

  • Find open and close smart quotes

    Dear scripter,
    Here I am trying find whether all the open double smart quotes(") are closed with close double smart quotes("). Here is my small work to find how many open and close quotes.
    myopenqu=app.activeDocument.search("^{", false, false, "^{");
    myclosequ=app.activeDocument.search("^}", false, false, "^}");
    myopenqulength = myopenqu.length;
    myclosequlength = myclosequ.length;
    if(myopenqulength!=myclosequlength)
    alert("Quotes not matched\n"+ myopenqulength +" Open quotes found\n" + myclosequlength +" Close quotes found")
    It works well, the script just alert if I have 25 open quotes and 23 close quotes
    Quotes not matched
    25 Open quotes found
    23 close quotes found
    Now I want to find the quote set where the 24,25th set close quotes are missing?
    Is there any way to find the misisng quotes
    Thanks in advance
    regards
    a r u l
    vpublish.net

    You'd have to look for unmatched quotes, in this case two cases of two open quotes without an intervening closed quote. This is difficult to script in CS2 because it doesn't have GREP natively and because of footnote problems. In CS3/4 it should be possible. But even then it will work only if you don't have quotes within quotes.
    Peter

  • Open and Close Front Panel of SubVI

    Hi all,
    Running LabVIEW 2011 on Windows 7 x64.  I am trying to get a subVI front panel to open from my main FP with the press of a button and then close with a button press in the subVI.  Here is the piece from my main FP that calls the VI and opens the FP 
    Plots is defined in another loop and all of the loops are in a flat sequence.  I did it this way because I want it to start with the first press and not stop my main loop from running.  I have moved the item in the left loop around a lot so I'm not sure if I can run that in the same loop as the event or not.  Either way opening the VI seems to work fine.
    The problem shows up when trying to close the subVI for the SECOND time.  The code is here:
    As I said, the first time I open and close the VI everything works as I expect it should.  I am then able to open it again but now the "blank button" doesn't function and I can't close the window or even open the block diagram to probe anything.  I have been trying to figure this out for awhile, any insite would be greatly appreciated!
    Thanks
    Solved!
    Go to Solution.

    Its good that you found the bug.
    This code may serve as a way for you to compare notes.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Open and Close Shelf Effect

    Relative newb to Flash and not sure what the issue is but I have a shelf opening and closing effect  The timeline is 45 frames long and when the shelf is out it has this AS3 code in it:
    import flash.events.MouseEvent;
    stop();
    ShelfOpen,addEventListener(MouseEvent.CLICK, closeShelf);
    function closeShelf(evt:MouseEvent){
    gotoAndPlay(17);
    Once clicked, the shelf closes and only a sliver of the shelf appears.   The person can re-open it by clicking the sliver at frame 30 using this code:
    import flash.events.MouseEvent;
    stop();
    ShelfOpen,addEventListener(MouseEvent.CLICK, openShelf);
    function openShelf(evt:MouseEvent){
    gotoAndPlay(31);
    In the last frame (45) I have the code:
    gotoAndStop(16)
    which should return the shelf to its open position and allow the user to close it again if they click in the shelf, but it seems to be listening at at frame 30 and just running the Open Shelf motion again.  I would just like the user to be able to open and close the shelf as they like.  Any help would be apprecaited.
    -DC

    See if removing the event lsteners in the event handlers helps, as in...
    ShelfOpen.addEventListener(MouseEvent.CLICK, closeShelf);
    function closeShelf(evt:MouseEvent){
       ShelfOpen.removeEventListener(MouseEvent.CLICK, closeShelf);
       gotoAndPlay(17);
    (similarly for the other)
    and make sure you are not using commas after ShelfOPen like you did in the code you posted.

  • Open and Close Posting Periods According to G/L Account Assignment Objects

    Hi,
    Can anybody please explain me how configurations related to " Open and Close Posting Periods According to G/L Account Assignment Objects " works in SAP FICO? I am confused about this config.
    Regards,
    Mandeep

    Hi Mandeep ,
    First i would like to tell about fiscal year
    fiscal year is nothing but a financial year of company in sap . it contain 12 normal periods and 4 special periods.In genaral we will call like month but that is sap that is a period. so 12 period for 12 months ok next special period will use in all companies for audit and tax adjustment purpose of previous year.
    coming to the open and close periods.in sap for security purpose we have to open one period like this month july so i opened july period only we cant post the pervious month (june)and we cant post future month lik in (Auguest)ok
    You can close and open periods by transaction ob52.
    In transaction ob52 there are account types
    + Valid for all account types
    A Assets
    D Customers
    K Vendors
    M Materials
    S G/L accounts
    V Contract accounts
    + means all types. if you want to open vendor then enter period from and to according to your fiscal year.
    you cant adjust items in closed period. if you want to then you have to open the period
    For your information.....
    posting periods also open user level tc S_ALR_87003642.
    customization levael OB52.
    Regards
    Kumar

  • Open and Close Posting Periods

    Hi Experts,
    When are are in open and close posting periods, we have
    From account to account
    From period 1 year to period & year
    From period 2 year to period & year
    Could you tell me difference between from period 1 & from period 2
    Regards.

    Hi,
    Open & Close Posting Periods
    This function is used to allow posting any particular account within a any desired period only. The variant type
    defined above is populated with characteristics i.e, in the combination of Variant type, Account type, Account Nos
    and Posting Period.
    Account types maintained by SAP are
    u2018+u2019 Valid for all account types
    Populating u2018+u2019 type is necessary even if all account types have
    been defined separately
    u2018Au2019 Assets
    u2018Du2019 Customers
    u2018Ku2019 Vendors
    u2018Mu2019 Materials
    u2018Su2019 G L Accounts
    u2018Vu2019 Contract Accounts
    Activity:
    Variant type frm a/c to a/c frm pd1 year to prd year frm pd2 year to prd year
    0001 + 1 2004 12 2005 13 2005 16 2005
    0001 A ZZZZZ 1 2004 12 2005 13 2005 16 2005
    0001 D ZZZZZ 1 2004 12 2005 13 2005 16 2005
    0001 K ZZZZZ 1 2004 12 2005 13 2005 16 2005
    0001 M ZZZZZ 1 2004 12 2005 13 2005 16 2005
    0001 S ZZZZZ 1 2004 12 2005 13 2005 16 2005
    Imp: u2018+u2019 type can be defined without u2018frm a/cu2019 & u2018to a/cu2019 limit, but for others i.e, A, D, K, M & S, a/c limits are required. However if posting periods are across accounts, u201Czzzzzzzzzu201D must be entered in u2018to a/cu2019 field.
    Assign Variants to Company Code
    Variant properties are assigned to a Company code.
    Regards,
    Sanju M S

Maybe you are looking for

  • IPhone SDK: runtime crash pushing viewController onto navigationController

    Hi, I have looked at this for hours but am completely stuck, any help would be much appreciated. I have the following code which pushes a viewController onto a navigationController: Scr1ViewController *scr1ViewController = [[[[Scr1ViewController allo

  • Use "Back to my Mac" for off-site TM backup?

    Can I use "Back to My Mac" for a Time machine backup. I'd like to setup a remote hard disk on my parent's iMac so I can backup remotely. I'll do the same for them on this site. Unfortunately, I suspect it's not that easy yet. We both have 1Mbps uploa

  • Recent experience with FileVault?

    Our University is coercing us to encrypt the hard drives of all laptops.  The preferred method is WinMagic SecureDoc, but they'll allow us to use FileVault on our Mac laptops (as long as we turn on encrypted VM).  It seems most of the FileVault infor

  • My iMac, running Lion, freezes.

    I just got a brand new, 2011 21.5 inch iMac, installed Lion, and whenever I play a video, usually youtube, my iMac wil sometimes freeze. It froze on me four times already, and when it freezes, the only thing I can do is move the mouse cursor. I can't

  • How to extract a WAR file..

    Hi, How to extract a WAR file.. please help me.. thanks in advance