Re-casting of object from control reference

I feel like this question is likely answered elsewhere, but after days of searching I couldn't find an answer. Sorry if I'm missing the answer in some obvious place.
I'm given a reference to a cluster control and told that the elements of the cluster are all children of parent class A. Using the controls[] property I get an array of the elements, and the value property of each of those elements gives a variant that can be turned into class A. At that point, all of the object oriented overriding and private data stuff works as expected.
So far so good.
But one method I call on those objects changes the private data, and I need to update the control with the updated object. There I get a runtime error because the control isn't A but some child class of A.
I think this is where Preserve Runtime Class comes into play, but since I only get a reference to work with, what do I do? This is especially frustrating because debugging probes show that LabVIEW knows the child class on the wire, but I can't see how to tell LabVIEW to cast down to the class that it knows it has.
For example, is there some way to use the ClassName property of the control to cast the object of class A into the child that the control is expecting?
Solved!
Go to Solution.

nathand wrote:
So your trying to write to the specific control within the cluster, by reference, as a variant, and you're getting an error? What's the actual text of the error?
Really you shouldn't ever be using a front panel object this way, especially one where the user never sees the data in it. For passing data around you should use a wire. Neither a wire nor a DVR will get you the ability to pass an arbitrary cluster, though, which it sounds like is what you're trying to do. With a bit more information we might be able to suggest a better approach.
I don't have the text of the error handy, but it comes from the write value property node and basically says the given variant can't be converted to the type of the control. It happens only when the value is cast to the parent class, which makes sense.
In other words, given a control of child type,
control.value ---> variant ---> to parent ---> variant ---> control.value     failes with the error
control.value ---> variant ---> to child ---> variant ---> control.value       succeeds
So a solution would be a way to cast to the child instead of to the parent. LabVIEW knows what class the control contains; it is listed in a number of places from the ClassName property through the probe window. The problem is I know of no way to bridge the gap from "LabVIEW knows what class this thing is" to "have LabVIEW cast the variant to that class."
I completely agree that I shouldn't have to ever be using a front panel control this way, but I don't want to get sidetracked into talking about the shortcomings of LabVIEW that have required such a use. Suffice it to say, that is the assignment.

Similar Messages

  • Error while deploying objects from Control Center Manager

    I got the error "The Network Adapter could not establish the connection"
    while deploying my objects (dimensions, cubes, mappings etc) from Control Center Manager Oracle 10g R2.
    Any idea to ressolve it..........

    Some more details would be helpful ...

  • ClassCastException on casting same objects differing in canonical name

    Hi all,
    I have got a problem with class casting. Some years ago I comitted the error not to bundle my classes in packages and now I need to do so. Unfortunately I can't deserialize previously saved objects from files anymore using ObjectInputstream, I get a ClassNotFoundException.
    file = new File(filename);
    FileInputStream fos = new FileInputStream(filename);
    ObjectInputStream oos = new ObjectInputStream(fos);
    try
         _transaktionen = (ArrayList) oos.readObject();
    catch (ClassNotFoundException e)
         JOptionPane.showMessageDialog(null, "Loading error (transaction)" +
                                            "\n"+e.getMessage());
    } Finding out their serialVersionID and make it explicit does not help either, so I created a copy of the class to deserialize in a package, since I need to reference to the class, and left anotherone in the default package.
    My problem now is that I can deserialize the objects, but cannot cast the object from the file to the type of the class in the package.
    //getting transactions from the arraylist previoulsy loaded from the file with iterator "it"
    DBFensterSeite aktuelleSeite =
                        new DBFensterSeite((Transaktion) it.next(), 1, null);Both have been loaded by the same ClassLoader, have the same serialVersionID and only differ in the canonical name (one is called Transaction, the new one is called packagename.Transaction). I am not quite sure whether this is the error, maybe you can help me. Thanks in advance!
    Regards,
    S�ren

    >
    Yes, technically you can. It does however require
    that you compile the new classes using a pre 1.3
    compiler. Then you just use them with the newer
    compiler.You mean, in Java 1.3 it was possible to reference classes in the default package?
    >
    You should look into providing a migration process
    however. Before installing the new application run
    another application that 'reads' the old stuff and
    'writes' it to a new location. That way your new
    application doesn't need to deal with the old stuff
    at all.Well, yes and no. The program implicitly executes a conversion on reading the file. Once you save it, it's in the new format (and thus unreadable for the old program). I do not want to provide a static conversion at installation time, because the customer, hopefully, backups data in the old format. He would not be able to read it after restoring data or, if there was something like a conversion function or program, would find it annoying having to think about it. In the end, they asked me to write the program for keeping it as simple as possible :-)
    I'm quite happy about the way it works now; the new cast-methods enable me to change the data types interfaces without having to bother about anything. ;-)
    Who gets the dukes now? :-p

  • Returning VI reference from control object reference

    Dear All
    I was wondering if there is anything that acts like inverse of "To more specific class" ? I mean it returns the VI reference from a reference to one of its control object? I think it is like moving upward in the hierarchy!!
    Is there any way to implement that?
    Best ragards
    Afshin
    Solved!
    Go to Solution.

    The property OWNER allows you to climb up the tree.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to reference multiple instances of the same Java object from PL/SQL?

    Dear all,
    I'm experimenting with calling Java from PL/SQL.
    My simple attempts work, which is calling public static [java] methods through PL/SQL wrappers from SQL (and PL/SQL). (See my example code below).
    However it is the limitation of the public static methods that puzzels me.
    I would like to do the following:
    - from PL/SQL (in essence it needs to become a forms app) create one or more objects in the java realm
    - from PL/SQL alter properties of a java object
    - from PL/SQL call methods on a java object
    However I fail to see how I can create multiple instances of an object and reference one particular object in the java realm through public static methods.
    My current solution is the singleton pattern: of said java object I have only 1 copy, so I do not need to know a reference to it.
    I can just assume that there will only ever be 1 of said object.
    But I should be able to make more then 1 instance of an object.
    To make it more specific:
    - suppose I have the object car in the java realm
    - from PL/SQL I want to create a car in the java realm
    - from PL/SQL I need to give it license plates
    - I need to start the engine of a scpecific car
    However if I want more then 1 car then I need to be able to refrence them. How is this done?
    Somehow I need to be able to execute the following in PL/SQL:
    DECLARE
    vMyCar_Porsche CAR;
    vMyCar_Fiat CAR;
    BEGIN
    vMyCar_Porsche = new CAR();
    vMyCar_Fiat = new CAR();
    vMyCar_Porsche.setLicensePlates('FAST');
    vMyCar_Porsche.startEngine();
    vMyCar_Fiat.killEngine();
    END;
    Thanks in advance.
    Best Regards,
    Ruben
    My current example code is the following:
    JAVA:
    ===
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED CODAROUL."RMG/BO/RMG_OBJECT" as package RMG.BO;
    public class RMG_OBJECT {
    private static RMG_OBJECT instance = new RMGOBJECT();
    private String rmgObjectNaam;
    private RMG_OBJECT(){
    this.rmgObjectNaam = "NonDetermined";
    public static String GET_RMGOBJECT_NAAM () {
    String toestand = null;
    if (_instance == null) {toestand = "DOES NOT EXIST";} else { toestand = "EXISTS";};
    System.out.println("instance : " + toestand);
    System.out.println("object name is : " + _instance.rmgObjectNaam);
    return _instance.rmgObjectNaam;
    public static Integer SET_RMGOBJECT_NAAM (String IN)
    try
    _instance.rmgObjectNaam = IN;
    return 1;
    catch (Exception e)//catch
    System.out.println("Other Exception: " + e.toString());
    e.printStackTrace();
    return 5;
    } //catch
    PL/SQL Wrapper:
    ==========
    CREATE OR REPLACE FUNCTION CODAROUL.SET_RMGOBJECT_NAAM(NAAM IN VARCHAR2) return NUMBER AS
    LANGUAGE JAVA NAME 'RMG.BO.RMG_OBJECT.SET_RMGOBJECT_NAAM (java.lang.String) return java.lang.Integer';
    Calling from SQL:
    ==========
    CALL dbms_java.set_output(2000);
    select CODAROUL.GET_RMGOBJECT_NAAM() from dual;
    Edited by: RubenS_BE on Apr 6, 2012 5:35 AM
    Edited by: 925945 on Apr 6, 2012 5:41 AM

    You can do this by manually creating a new iterator binding in your binding tab.
    So instead of dragging the VO directly to the page, go to the binding tab, add a new executable iterator binding, and point to that one from your ELs in the page itself.

  • Accesing controls (references) from several VI's

    Ok I have this small problem:
    I have a large program
    and have put serveral "advanced settings" in a different VI.
    Result
    is that the values entered here need to be passed to controls in
    different other VI's
    The way I use this now is using 1 element
    queues to pass the control
    value. 
    For one VI I can create control
    references, call a sub vi and put here the control that can manipulate
    the value.
    How do I achieve this for multiple VI's? Is
    there a way to make control values from ANY running VI available? Maybe
    using xcontrols? I have no idea how to achieve this though.
    thanks!

    Ben wrote:
    I will typically use a GUI controller in my apps to accomplish that type of thing.
    GUI Controller
    I develop an Action Engine  that will cache a cluster of control references when an Init method is invoked. This put all references in a SR that can be accessed from any place the Ae is used.
    I add methods to the AE to take care of screen settings associated with changes of state ("Set Visability Edit Mode", "Set Visablilty Login", etc).
    I also add a method to return the cluster of refs so I can use them to set-up dynamic event registration in sub-VI etc.
    A side benfit of using a GUI Controller is that you have a single point where you can add a "stack" of screen views so functions like "Back" and "Forward" can be added easily. 
    So...
    trying using a GUI Controller.
    Ben
    This an excellent method for achieving what you want. A variation of it would be to use LVOOP instead of the AE. The two approachs are essentially the same but with some thought on the definition of the classes I imagine you can create a general purpose base class to handle most of the common aspects. Customizations can be achieved using derived classes.
    Further adding to Jeff's comments about the up front hit in the schedule. When done right you will see the benefits of shorter schedules for future projects. The first time is the hardest sell to management. However once you get a couple of successes under your belt future requests will be much easier since you now have a track record of benefits achieved by using reusable code libraries.
    Message Edited by Mark Yedinak on 03-30-2010 08:55 AM
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • How to reference a Textbox or a Grid object from one tile to another tile

    Hello All
    How do i reference a Textbox of a Grid object from one tile to another tile? I've 6 tiles in a tileset.
    Tile-1 has a "Complete" button when that button is clicked i want to loop through a values in a Grid object from Tile-3. Is that possible? I'm using Mobile Application Studio 4.0
    Thanks in advance,
    Hetal

    Hi,
    then I would implement sth like the following:
    dim myBO as businessobject
    dim i as integer, sValue as string
    for i = aMyAnchor.bcol.count to 1 step -1
      sValue = aMyAnchor.bcol.GetAttribute(i, "myProperty")
      if sValue = "" then
        aMyAnchor.bcol.item(i).delete
      end if
    next
    Please note that the deletion needs to be done bottom-up because of a refresh of the
    indexing after deleting of objects in the collection.
    The refresh of the grid is done automatically because of the data binding.
    Regards,
    Wolfhard

  • Creating a dynamic event from a control reference

    Does anyone have an example of creating a dynamically driven  event from a control reference?

    Hi 4BoysDad,
    There is a good example that can achieve what you're looking for in the example finder.  It is called "Dynamically Register For Events.vi".  It will be under
    <labview>\examples\general\dynamicevents.llb\Dynamically Register for Events.vi
    Regards,
    Che T.
    Applications Engineer
    National Instruments

  • Get a reference to an object from a touch

    I have no idea how to get the reference to an UIImageView object from a touch gesture. So far all I know how to do is get a reference to the touch. This is the code I have so far:
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    printf("TOUCH ");
    UITouch *touch = [touches anyObject];
    CGPoint touchPoint = [touch locationInView:self.view];
    Any help would be greatly appreciated

    There may be more elegant methods, but what I did was to find out which sub views bounds covered the coordinates of the selected point. My task was easy since I had a sudoku grid, so converting coordinates into the index into an array of view instances was easy.
    - (unsigned int) setSelectedIndexForXCoordinate:(float) x YCoordinate:(float) y
    int column = (int) ( ( 9.0 * x ) / 320.0 );
    int row = (int) ( ( 9.0 * y ) / 320.0 );
    unsigned int index = ( ( row * 9 ) + column );
    [self setSelectedIndex:index];
    return index;

  • How to remotely control objects from transport request

    Hi all,
    I have to perform some task but can't find the way to get it done. What I have to do is:
    a) get list of transport requests for given SAP system (i.e. its import queue)
    b) let the user choose transport requests from the list
    c) get list of all objects from chosen transport requests
    d) control these objects in source and destination (from point a) ) SAP system. 
    Points a) to c) are easy and already done (using appropriate function modules and ALV objects). But I have no idea how to do things from point d). Control means comparison of dates (i.e. last modified) of objects in source and destination SAP system. The main goal of this approach is to avoid transportation of older objects from source system (DEV) and overwritting newer versions of the objects in destination system (PRD). I tried to use SAP versioning system to check versions remotely (the same way as it can be done from standard SAP transactions, e.g. SE38 for program source) with RFC and it worked fine (see function module SVRS_DISPLAY_REMOTE_DIR). But what about other objects not covered with versioning system? There are 932 objects that can be transported (at least TR_OBJECT_TABLE function module says so). Versions management system covers about 30 (program source, function module, object methods, table definitions, lock objects, and so on) of them. The problem is with the rest (900 transportable objects).
    How can I check their dates remotely in source and destination SAP system. Any clues? Manual retrieval of the information about dates of 900 various SAP elements must be very difficult (if possible at all) because so many objects must be spreaded out in many tables. Is there any universal or standard way (report, RFC function module) to get required information?
    Thanx in advance,
    Jacek Witczak

    Hi
    There is no automatic way to delete the unnecessary objects from the transport reqeust.
    1. Go to Tcode se09 and select the request which contains the unnecessary objects.
    2. Select the unnecessary objects and delete manually.
    Also if you want to delete the entire request then unlock the request in the tcode SE03 and then delete the request completely.
    Also note that if the request is released then you will not be able to delete the objects in that request.
    Hope it helps.
    Regards
    Sadeesh

  • Reference HttpServlet object from webservice method ...

    How to reference HttpServlet object from webservice method to access HTTP header?
    Thanks
    Marcel

    You are correct.
    I know that SOAP messages can be send not only via HTTP protocol.
    Our solution is restricted to use only HTTP protocol for communication between client and server by customer, because there is implemented transparent proxy for users authorization and strong security of communication via HTTP protocol. Authorization server transparently modify HTTP request header with user identity (DN from user certificate - with this PKI solution it is not possible to use standard SSL because certificate is proprietary enhanced and cannot be accessed in standard way). That is why I need access HTTP request header.
    Why I want to use webservices? I thing that webservice is flexible and perspective technology for integration and asynchronous communication between web clients and application (it is really more effective add new info in web page asynchronously from webservice than reload whole page).
    Thanks
    Marcel

  • 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

  • Control references/refnums: general info

    Please forgive this question, I am a relatively new LV programmer and the help files & manual seem quite poor to me!
    I am after some basic information about control references & refnums as I am sure they would be of help to me.
    1. What are the main advantages in using them? (i.e. what they can achieve)
    2. How are they implemented?
    3. How is a control refnum/reference passed from one VI to another programmatically?
    Huge thanks to anyone who may be able to shed some light on this topic.
    Dan

    > 1. What are the main advantages in using them? (i.e. what they can
    > achieve)
    The references let you access properties and methods of controls on a
    front panel. Previously, the access was limited to the diagram of that
    panel, and each property node accessed a single particular control.
    With control refnums, you can have one property node access an arbitrary
    control with the refnum parameter controlling which one. You can also
    send the refnums to subVIs meaning that the code can be abstracted to
    simpolify your diagram and shared with other panels.
    > 2. How are they implemented?
    I assume you want to know how to use them. You right click on the
    control or its terminal and under the create menu, next to where you can
    create an implicit property node, you can also create a Reference node.
    The datatype of this node is unique to the type of control that you
    created it from, and when wired to a property node, the property node
    will show the same properties as an implicit one. As an example, if you
    have 8 Boolean buttons on your panel that need to be enabled, disabled,
    hidden, colored, labeled, or whatever based upon the state of your
    application. You can right click on the eight buttons creating
    Reference nodes and build an array of the references. You can now loop
    through your array and with one property node, set the properties of the
    buttons based upon whatever logic or table of information that you need.
    You can also do this in a subVI by passing the array of references to
    the subVI.
    It is also possible to get control refnums/references from other
    properties. For example, a slider will give the reference to its
    digital display, a graph will give references to its cursors, etc. It
    is also possible to loop through the references of all objects on the
    panel inspecting names or types rather than using the Create Reference
    popup, but this is more advanced and requires casting the references.
    If you really want to know how they are implemented, it is much like
    file refnums or VISA refnums. I can give more info if you ask a more
    specific question.
    > 3. How is a control refnum/reference passed from one VI to another
    > programmatically?
    >
    In the refnum palette there is a Control/VI refnum control. You drop it
    on your subVI and right click to set the class. Note that there are
    lots of classes arranged from basic to very specific. Class refnums
    will convert to more basic automatically, but will not wire if they are
    incompatible. So, if you are careful, you can select the class from the
    menu and create the control refnum that you can wire to the connector
    pane allowing you to pass refnums into the VI. A shortcut that is a bit
    simpler is to draw the reference from the diagram to the subVI panel.
    It will make the correctly typed control refnum for you, ready to wire
    to the connector pane.
    That is sort of the basic overview. You probably want to look at the
    example -- general/cntrlref.llb/Property Nodes.vi. I also suspect that
    the devzone contains other examples showing how they can be used.

  • Data acquisition with control references

    I'm a new LabView user and I would like to acquire data in a subVI and display that data in the main VI. I think that I need to use control references and refnums, but I just haven't been able to figure it out. I would GREATLY appreciate any help I could get.
    Thank you!

    From your description I would guess that the "subVI" has a loop in it that repeatedly reads the FP hardware, and the indicator is inside the loop. Right?
    The thing to do is move a lot of the logic in the subVI up to the Main VI--or add the Main's added logic to the subVI, whichever is easier. In the first case, the subVI would go away, in the second, the subVI would become the Main VI.
    If you're confused, post your code in V6.0 format and I'll show you what I mean.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Class cast exception in Process Control

    Hello,
    I am trying to use a SubProcess through a Process Control from a ParentProcess in another Workshop application.
    They are both deployed in the same domain.
    The SubProcess Control is packaged in a Control Project whose jar is imported in the other ParentProcess Workshop application.
    The data that is passed is in form of XML documents described as schemas. And both applications use the same Schema.jar.
    The call from the ParentProcess looks like it is OK.
    But when the reply comes back it looks like the transform fails. I get a "class cast exception"
    The feeling I get is that the returning xml document variable can't be cast into the local xml document variable. Even though they are of the exact same type...
    All help is very much appreciated!!!
    Unhandled Process Exception:
    java.lang.ClassCastException
    at se.telia.object.kund.control.sokKundPControl.clientRequest(Unknown Source)
    at se.telia.tab.regae.process.Untitled.sokKundPctrlClientRequest(Untitled.jpd:101)
    -------------

    I'm having some problems with a transformation and I'm getting a cast exception so maybe it's the same thing.
    The problem is when the source schema has some element with minOccurs="0". If the element is not present in the xml document that is received, the transformation seems to be trying to cast it anyway.

Maybe you are looking for

  • I keep getting the alert window that says, "the url is not valid and cannot be loaded"

    My computer is "online" but whenever I try to get on a website, the "Alert" box pops up in the middle of my screen saying, "the URL is not valid and cannot be loaded". This is only happening on Mozilla Firefox, I am able to use Internet Explorer with

  • What's with the slow gets from my ResultSets?

    I have two databases, an Omnis and a MySQL. I'm trying to copy the data from the Omnis into the mysql, but the getXXX(int i) methods acting on my ResultSet are LUDICROUSLY slow... to transcribe a meager 2660 entires (with 15 columns) takes a staggeri

  • Hyperion System 9 BI+ 9.3 Administrator certification

    Dear All, could you please provide me the good study material for the prepration of the certification exam for "Hyperion System 9 BI+ 9.3 Administrator" Thanks in advance. Regards, Ashish

  • Feedback on the potential use of the tool and about the Task Life Cycle

    Hi The task statuses does not considers some statues. We have worked on the task lifecycle for workflows (see image below). You are missing: Created, offered, allocated before getting the category of not started because otherwise your problem might b

  • Webpage looking funky in Safari

    Hi! I'm having trouble with my menu text coming out aligned vertically when viewed in Safari. In Firefox it looks as it should: http://www.imageox.com/image/362619-Bild2.png But in Safari it looks like this: http://www.imageox.com/image/362620-Bild1.