Pass control references to subVI using Invoke Method

Hi guys,
Can I use <Control Value Set invoke method> to pass some control references to a sub VI, then use the <Run VI invoke method> to run the sub VI with the previously passed data?  The control refnums are for some frontpanel controls in the Main VI.
I was able to pass other data but the refnum didn’t work.
Thanks

Hi there, There are a couple examples that use the same method. Check them here:
- Set Control Values and Trigger UI Events in Another VI        
- Set Values and Properties of Controls in a SubVI
- Save and retrieve front panel control values
Alejandro | Academic Program Engineer | National Instruments

Similar Messages

  • Passing control reference to subVI crashes labview

    Hi,
    using a image control (as indicator) provided by imaq Vision, I tried to pass the reference of the control to a subVI. On a computer it works and on a other (same labview version, same vision version, same os, same hardware and hardware drivers!), this crashes labview. I tried to close the control refnum at the end of the subVI, but that changed nothing to the issue. Now I use the reference as a global variable and it seems to work...nevertheless, I would like to understand what the issue and if I should remove any passing to subVI of control ref because this can potentially triggers an error. My correlated question is if this global passing is a "fake" workaround or have real chance of improving (this before going through the whole code for changing all passing of reference to subVI)
    thanks a lot

    Hi,
    thank CoastalMaineBird for your answer
    How do you know it's this issue which causes the crash?
    When I remove this parameter from and the only property node in the subVi that write to it, I have no longer any problem. Moreover, to ensure that's really the "passing", and made a global variable containing the reference to this control and use my original SubVi that do access the control through its reference number
    , and it works! In this last exemple, the only change is the way of transmitting the reference
    What LabVIEW version?
    8.0.1
    up to date according Measurement & Automation update tool
    Given that one computer works OK, and another crashes, I would say that
    you are seeing the effect of something else, not the cause. If passing
    a control ref via terminals was fatal, it would be fatal all the time.
    You have some other sort of issue, perhaps timing of the different
    machines triggers the bug, perhaps running out of memory, perhaps
    LabVIEW is corrupted on one machine.... But I don't think changing all
    your code to use globals would solve the real problem. Actually, saying that I wonder about problem of synchronisation. I know from Visual C++ that this kind of error happens if two process try to access the same control at the same time. This is typically an error changing from a computer to an other, and mutex or semaphore are the way to deal nicely with that. But does labview contains already such a securisation? If so, the global variable point on a single object and can "fell" the semaphore/mutex. But passing make a copy that will likely have two different semaphore/mutex but will point to a single control! Do someone know if I'm wrong in this idea or not?
    Thanks

  • Reading DMA FIFO using Invoke method node

    Hi
    I am trying to read a DMA FIFO using invoke method node to read the data in the FIFO on RT.
    It works fine but the problem is that it consumes a lot of CPU if the timeout is increased. Can
    anyone tell why this is happening and if this is the desired behaviour then what other methods i can
    use to avert this.
    Please help at the earliest
    Regards
    Amit

    Hi
    Can anybody help me as it is urgent ,
    What i further found out is that is that it is eating up a lot of meory when continuosly polled up in a looop....
    Regards
    Amit Ahuja

  • How can I duplicate a control in a subVI using the reference?

    Here's what I want to do. I have a tree control in my main application. I add and delete items dynamically based on user input. If I pass my tree reference to a subVI, I can add, subtract and reorder the items in the tree and the changes are shown on the main tree. How can I duplicate the tree in the subVI? Would I simply pass the tree control in (which I'd rather not do) or is there some other way to accomplish this?
    Thanks in advance for any help.
    Gary

    Here's my attempt.  This VI uses a control reference of the old tree and generates a data structure that can be used by the "Edit Tree Items.Add Multiple Items to End" method to add contents to the new tree that should be identical to the contents of the original tree.  Note that this VI only works with LabVIEW 8.0 and later, since the afore-mentioned method is not available in previous versions.
    I hope this helps...also note that I saw some re-draw issues with LabVIEW 8.0, i.e. after the VI ran, I didn't see the tree displayed properly until I minimized/restored the window, or dragged another window over it.  I did not see the redraw issues in LabVIEW 8.2.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman
    Attachments:
    Duplicate Tree.vi ‏21 KB

  • Control references as subVI input

    I have a subVI which accepts control references as input. But these are optional inputs. I have code in the subVI whcih uses the refernecs. I want this code to execute only if the control refernce inputs are wired from the main VI. Is there any way I can check whether the control refernce inputs were wired in the main VI? 

    You can use Not a Number\Path\Refnum from the Comparison palette or you can type cast the reference to a numeric and check if it is not equal to 0. There are probably some other ways.
    Try to take over the world!

  • Pass as a parameter or use set() method?

    This question may be a bit too abstract:
    A method of ClassB needs the HashMap member variable 'map' from ClassA. Should I pass map as a parameter into a method of ClassB, i.e.
    ClassB b = new ClassB();
    b.aMethod(map);or should I use a set() method in ClassB to set a member variable of type HashMap in ClassB, i.e.
    ClassB b = new ClassB();
    b.setMap(map); //sets the HashMap member variable in ClassB to equal map
    b.aMethod(); //aMethod now performs its operation on the HashMap member variable of ClassBHow do you decide which way is prefereable?

    Depends on your model, I suppose. Form the example, though, I wouldn't make the map a member of Class B, unless Class B should logically possess such a map. If the method in Class B is just operating on some values from the map, it makes more sense to me just to pass it in as an argument.

  • Crash when using Invoke Method: Library:Deploy Library

    I'm trying to set a library of shared variables to deploy when a VI runs. When using the method to deploy a library, Labview will crash with no error log. I am able to use Library.Open to, for example, HiliteInProjectWindow, and Library.GetFileLVVsersion (8.6). But for the life of me I cannot get deploy to work. Any ideas?

    hbcnb,
    I'm not quite sure why that is happening, but I
    can give you a work around for it.  There is a property node that
    returns the mode that LabVIEW is running in (Run-Time, Development,
    Evaluation).  If you output this value to a case structure, you can
    include your deploy code in the run-time version but not in your
    development version so that it will cease to crash.  Place down the
    property node, then select  Application » Kind.  I've included a
    picture of how to wire this up. Let me know if this helps work around
    the problem a bit easier.  
    Sincerely,
    Chris G in AE
    Attachments:
    application_pic.jpg ‏27 KB

  • When i used invoke methode with read out variants array byte crashd my LV by recal the second repeat?

    If i check it with VBASIC it runs fine, check it to run with Delphi its fine, wot is wrong with LV 6.02

    You may want to contact National Instruments directly. Try: www.ni.com/ask
    Brian

  • Pass by reference and String

    public class Test {
        static void method(String str) {
            str = "String Changed";
        public static void main(String[] args) {
            String str = new String("My String");
            System.out.println(str);
            method(str);
            System.out.println(str);
    }The output is
    My String
    My String
    How this is possible when objects are passed by reference ?

    > How this is possible when objects are passed by reference ?
    All parameters to methods are passed "by value." In other words, values of parameter variables in a method are copies of the values the invoker specified as arguments. If you pass a double to a method, its parameter is a copy of whatever value was being passed as an argument, and the method can change its parameter's value without affecting values in the code that invoked the method. For example:
    class PassByValue {
        public static void main(String[] args) {
            double one = 1.0;
            System.out.println("before: one = " + one);
            halveIt(one);
            System.out.println("after: one = " + one);
        public static void halveIt(double arg) {
            arg /= 2.0;     // divide arg by two
            System.out.println("halved: arg = " + arg);
    }The following output illustrates that the value of arg inside halveIt is divided by two without affecting the value of the variable one in main:before: one = 1.0
    halved: arg = 0.5
    after: one = 1.0You should note that when the parameter is an object reference, the object reference -- not the object itself -- is what is passed "by value." Thus, you can change which object a parameter refers to inside the method without affecting the reference that was passed. But if you change any fields of the object or invoke methods that change the object's state, the object is changed for every part of the program that holds a reference to it. Here is an example to show the distinction:
    class PassRef {
        public static void main(String[] args) {
            Body sirius = new Body("Sirius", null);
            System.out.println("before: " + sirius);
            commonName(sirius);
            System.out.println("after:  " + sirius);
        public static void commonName(Body bodyRef) {
            bodyRef.name = "Dog Star";
            bodyRef = null;
    }This program produces the following output: before: 0 (Sirius)
    after:  0 (Dog Star)Notice that the contents of the object have been modified with a name change, while the variable sirius still refers to the Body object even though the method commonName changed the value of its bodyRef parameter variable to null. This requires some explanation.
    The following diagram shows the state of the variables just after main invokes commonName:
    main()            |              |
        sirius------->| idNum: 0     |
                      | name --------+------>"Sirius"       
    commonName()----->| orbits: null |
        bodyRef       |______________|At this point, the two variables sirius (in main) and bodyRef (in commonName) both refer to the same underlying object. When commonName changes the field bodyRef.name, the name is changed in the underlying object that the two variables share. When commonName changes the value of bodyRef to null, only the value of the bodyRef variable is changed; the value of sirius remains unchanged because the parameter bodyRef is a pass-by-value copy of sirius. Inside the method commonName, all you are changing is the value in the parameter variable bodyRef, just as all you changed in halveIt was the value in the parameter variable arg. If changing bodyRef affected the value of sirius in main, the "after" line would say "null". However, the variable bodyRef in commonName and the variable sirius in main both refer to the same underlying object, so the change made inside commonName is visible through the reference sirius.
    Some people will say incorrectly that objects are passed "by reference." In programming language design, the term pass by reference properly means that when an argument is passed to a function, the invoked function gets a reference to the original value, not a copy of its value. If the function modifies its parameter, the value in the calling code will be changed because the argument and parameter use the same slot in memory. If the Java programming language actually had pass-by-reference parameters, there would be a way to declare halveIt so that the preceding code would modify the value of one, or so that commonName could change the variable sirius to null. This is not possible. The Java programming language does not pass objects by reference; it passes object references by value. Because two copies of the same reference refer to the same actual object, changes made through one reference variable are visible through the other. There is exactly one parameter passing mode -- pass by value -- and that helps keep things simple.
    -- Arnold, K., Gosling J., Holmes D. (2006). The Java� Programming Language Fourth Edition. Boston: Addison-Wesley.
    ~

  • Finding vi running in subpanel from a subpanel control reference?

    I've poked around considerably and cannot find a way to take a control reference to a subpanel control and get the vi reference for the current vi running inside the subpanel.
    I know I can save this locally inside the vi containing the subpanel (from the invoke node call to insertvi), but I'm wanting to do this externally from an app that just has references to all the controls.
    Any help would be greatly appreciated.
    Thanks

    If I'm interpreting you correctly, you would like to find the VI reference of the subpanel VI based off one if it's control references that has been passed to some external application from the VI that contains the subpanel VI?  See the attached VIs for an example if this is the case.
    "VI with subpanel" passes a control reference to "SubVI" which can then get the reference to the "VI in subpanel".
    I grabbed the original files from here:
    http://digital.ni.com/public.nsf/allkb/0B11E4964685B49F862571430000091E?OpenDocument
    Trey B
    Applications Engineering
    National Instruments
    Message Edited by Trey B on 07-24-2007 11:30 PM
    Attachments:
    VI in subpanel.vi ‏27 KB
    VI with subpanel.vi ‏29 KB
    subVI.vi ‏8 KB

  • Get image invoke method gives blank image when I try to capture waveform graph picture

    Hello
    I am facing problem when try to capture waveform graph picture using invoke method Get image and write JPEG function, some times it gives blank images.I am using these functions inside nested loops.
    ObservationsWith reference to attached VI)
    (1) Sometimes  I found it captures images correctly when i run labview program first time but after that it starts writing blank images.
    (2) Whenever i use flat sequence structure for waveform graph and get image node it always gives blank picture which indicates that execution of waveform graph and Get image should not be sequential.
    (3) Whenever it gives blank image i checked the image data which is not valid data so it indicates problem is with Get image method or labview program flow(may be race condition between waveform graph and Get image method).
           I have attached vi ,please change path name and folder name in which images are being saved.I'm using labview 8.5.1 .
    Attachments:
    image_capture_problem.lvproj ‏6 KB
    image capture problem.JPG ‏149 KB
    0.0_10__3.jpg ‏2 KB

    Hi,
    I have tried sequence structure.But sometimes it also gives blank images. I have attached new vi which is using flat sequence. Run this vi 7-8 times then you will observe blank images. I don't know why?Any help will be greatly appreciated.
    Attachments:
    image_capture_problem.vi ‏69 KB

  • Unable assign a BPM Object field value to a JSP Variable using "invoke"

    Hi,
    I'm unable to retrieve a value returned by a BPM Object Method and use it in JSP. Here is what I'm trying to achieve:
    BPM object named : "myObject" has a method "getRequiredValue" which returns a "String". I want to assign the value returned by "getRequiredValue" to a JSP Variable "myVariable" using invoke method as below:
    <% String myVariable = ""; %>
    <f:invoke var="${myObject}" methodName="getRequiredValue" retAttName="myVariable"/>
    <% out.println ("myVariable: " + myVariable); %>
    When I execute the above code I don't get the value being returned by "getRequiredValue" into "myVariable".
    Any help would be highly appreciated!
    regards,
    MK

    1. Make sure you mark the "Server Side Method" property of the getRequiredValue method to "Yes".
    2. I guess you dont need to specify "<% String myVariable = ""; %>". Try removing it.
    3. Replace "<% out.println ("myVariable: " + myVariable); %>" by <c:out value="${myVariable}"/> just in case!
    4. Lastly, I hope "myObject" is the name of the instance variable in your screenflow, and not the BPM object name.
    Hope this helps
    -Hemant

  • How BAPI Tables parameters are passed by reference

    Hi Gurus,
                     I have a genuine doubt regarding BAPI parameters. I would like to point out the genreal rules of bapi like,
    1. BAPI parameters should be passed by value. (Because they are rfc fm's. So both systems will be in different servers. This is the normal scenario.)
    2. But the tables parameters in BAPI can't be passed by value. Instead they are passed by reference.
    3. I know they use some kind of delta mechanism to transfer tables parameters to remote servers.
    So gurus I would like to know what exactly happens when a tables parameter is passed. And also I didn't understand the delta mechanism. Kindly guide me.
    Thanks in advance,
    Jerry Jerome

    You'll see in [SAP Library - RFC - Parameter Handling in Remote Calls|http://help.sap.com/saphelp_nw04s/helpdata/en/22/042551488911d189490000e829fbbd/frameset.htm] that tables are not passed by reference when you use RFC. It also explains the delta.
    When you make a remote function call, the system handles parameter transfer differently than it does with local calls.
    TABLES parameters
    The actual table is transferred, but not the table header. If a table parameter is not specified, an empty table is used in the called function.
    The RFC uses a delta managing mechanism to minimize network load during parameter and result passing. Internal ABAP tables can be used as parameters for function module calls. When a function module is called locally, a parameter tables is transferred u201Cby reference". This means that you do not have to create a new local copy. RFC does not support transfer u201Cby referenceu201D. Therefore, the entire table must be transferred back and forth between the RFC client and the RFC server. When the RFC server receives the table entries, it creates a local copy of the internal table. Then only delta information is returned to the RFC client. This information is not returned to the RFC client every time a table operation occurs, however; instead, all collected delta information is passed on at once when the function returns to the client.
    The first time a table is passed, it is given an object-ID and registered as a "virtual global table" in the calling system. This registration is kept alive as long as call-backs are possible between calling and called systems. Thus, if multiple call-backs occur, the change-log can be passed back and forth to update the local copy, but the table itself need only be copied once (the first time).

  • Recursive Function, Pass by "reference"

    I need to create a function and build an Arraylist.
    public void buildList (String s, Arraylist list) {
    ....//code specific to application
    list.add(something);
    buildList(somestring, list);
    public void anotherFunction(){
    buildList(str, myList);
    Will myList contain the values that are added? Is this only a copy of the list?

    Java always passes by value.
    (Now it gets confusing)
    In this case it passes a reference by value.
    The method gets its own variable for storing the reference to the list in.
    ie it is the equivalent of saying
    Arraylist list = myList;
    It doesn't copy the entire list, it just gets a reference to it.
    If you change the contents of the list by calling list.add() then original looks like it was updated, as they point to the same thing.
    If you execute
    list = new ArrayList();
    Then list becomes distinct and seperate from the myList variable in the calling procedure.
    If java was pass by reference, when you execute list = new ArrayList it would also change the value of the variable in the calling procedure. That doesn't happen.
    Hope that clears things up,
    evnafets

  • Using "Set Control Value" to pass a reference

    Hi,
    every time I tried to passe a Control Reference using "Set Control Value" I have the Error 1 (invalid input parameter at invoke node). Why is it not possible to pass a control reference using the invoke node??
    Thanks
    Golzio

    Hi,
    This is possible. Trick is, the type of the control reference needs to be
    the same as the input. E.g. a string control reference is a different type
    as a numeric control reference (, or a control reference).
    To avoid this conflic, make sure the input of the vi is a control reference
    (and not a e.g. string control reference). Also make sure the to convert the
    reference you pass to a control reference (using Application Control>To More
    Generic Class).
    Regards,
    Wiebe.
    "Golzio" wrote in message
    news:506500000008000000C1F00000-1079395200000@exch​ange.ni.com...
    > Hi,
    > every time I tried to passe a Control Reference using "Set Control
    > Value" I have the Error 1 (invalid input parameter at invoke node).
    > Why is it not possible to pass a control re
    ference using the invoke
    > node??
    >
    > Thanks
    > Golzio

Maybe you are looking for