Graph control reference array conflict

My vi has 6 graphs, and I need to modify them through property nodes through out my vi, so I wanted to store all the graph references into an array and pass it along.  When I do that, I am getting a class conflict between my input array and array in cluster.  They are both waveform Waveform Graph Refnum (strict), so I am not sure why there is a conflict.  See attachment for additional info.
Kudos and Accepted as Solution are welcome!
Solved!
Go to Solution.
Attachments:
ref.PNG ‏4 KB

all elements of an array can differ only in value and must be exactly the same type of data in  this case ref classes. WHen you build an array from diferent ref types LV find the common class shared by all elelements of the array and cast them all to that type. Extreme case... if you included a boolean in your array the only property you would find are visable and lable (may a fw more).
So by using a cluster each ref can be different and provided I coded it right be exactly the strict ref of the original and there allow me to access all of the properties associated with that class of control.
I hope that cleared up some confusion,
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction

Similar Messages

  • Can you use a control reference for a graph with two channels of data?

    when i try to wire a 2-D array of data to the value property of a graph(strict control reference), it shows a conflict. The value data type only shows up as accepting a 1-D array input. I want to use control references to pass the chart data to my main vi. Will I have to change the waveform graph control reference into an array control reference to make this work?? This would require adding a while loop in the main vi to read the array data and update the graph data??

    > when i try to wire a 2-D array of data to the value property of a
    > graph(strict control reference), it shows a conflict. The value data
    > type only shows up as accepting a 1-D array input. I want to use
    > control references to pass the chart data to my main vi. Will I have
    > to change the waveform graph control reference into an array control
    > reference to make this work?? This would require adding a while loop
    > in the main vi to read the array data and update the graph data??
    I think the problem is that your waveform graph is set to take one type,
    a 1D array of doubles, and you are wiring a different type. While
    charts adapt to type when the data is wired to their terminal, they do
    not adapt to data wired to their value property. If you change the
    datatype of the graph from its terminal, then you should see the value
    property change type also and you are set.
    Greg McKaskle

  • Control references and XY graph

    hi there,
    I was wondering if somebody can help me with passing data to a " XY graph
    " not waveform graph [ in a main VI ]
    from a sub vI using the concept of a control reference..
    p.s: I dont intend to flatten data .
    It works fine with waveform graph but there is nothing to show ( even
    examples ) me how to do it with XY
    graph.
    thanks.
    ananth

    In the example, why is the control reference outside the case statement, since the graph
    is only updated when plot=true the ref belongs inside or did I miss something?.
    ananth wrote:
    > thanks
    > and you said it right. that was the problem.
    >
    > "John Lum" wrote:
    > >>>I was wondering if somebody can help me>>with passing data to a " XY
    > graph" not>>waveform graph [ in a main VI ] >>from a sub vI using the concept
    > of a>>control reference.. >>I don't see any problems here using LabVIEW 6.0,
    > and I'm wondering if you're>having trouble with a Variant input or something.>>Here's
    > an example of a subVI that spits data into a main VI's XY Graph by>way of
    > a control reference>ftp://ftp.ni.com/incoming/xy.zip>>Regards,>John Lum>Na
    tional
    > Instruments

  • Given array control reference, how do I obtain array size programatically

    If an array control reference is passed to a sub-vi, how do I obtain the current length of the array within the sub-vi?  I've tried two properties:  "NumRows", which as documented, contains the visible number of rows in the array control.  "IndexVals" contain the indices of the array element in the upper left corner of the array control.  There seem to be no methods for obtaining the current array length.  I tried changing the class of the array reference to cluster then using the "Controls[]" property... but this generated a runtime error.  What am I missing?  Thanks.
    Solved!
    Go to Solution.

    Taki1999 wrote:
    There's a lot of casting going on in your subvi.
    What is the actual use case?  There might be a way to do this which doesn't require the casting and you could work just with the reference that is passed in.
    For your method you need to wire in a strict class specifier into the To More Specific Class conversion.  I'm not sure how to make the strict class specifier.
    I can help with that but first...
    Working with arrays on unknown data types is no esy task and determining the size is a special challenge and I did just that in this Nugget that talks about using control references. This task is much easier when you know at development time what is in the array. That is where the strict type casting comes into play.
    What I would do...
    1) Make sure the contents of the array is a type def (to support data strcuture changes in the future).
    2) Go to the FP of the VI that has the array in question and drop a generic control ref control.
    3) Ctrl-copy and drag the array in question INTO the the generic ref (still working on the FP). You can tell when you find the "sweet spot" in the ref control because it will switch it appearence. See this mini-nugget for an image where the same thing can be done with que refs.
    4) Make the now strict ref a type def.
    5) Use the type-def'd ref from step #4 in the sub-VI as the proptype used by the "To More Specific...."
    After those changes you should be able to work with array in the sub-VI as if it were in the top level.
    BTW:
    Doing the above on the control in the sub-VI that brings in the ref would allow skipping the "To more Specific..."
    Have fun!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • 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.

  • Control references vs. global variables

    I guess my question centers on the appropriate application of control references.
    I am writing a complex program that has a state machine at the top level, and, for one frame of the state machine, a while loop containing a couple subVIs, each of which contains many subVIs. The lower-level subVIs are affected by buttons on the top-level VI. Information from the lower-level VIs must be shown on the top-level front panel within the loop. My question is: what is the best way to do this?
    (I have a previous version of the program that I wrote that keeps just about everything on the top level so that I can update the front panel, but this is not at all modular.
    In addition, I considered breaking things up into more than on
    e front panel, but this doesn't seem to be a good option for this section of this program.)
    Last week I read about control references, and decided that this could be the way to deal with this issue. I have not worked with them before, so I want to know: Are control references an appropriate solution for this issue? Is it good programming practice to use them, especially to update data on charts and graphs? How do they compare programming-wise and efficiency-wise to global variables?
    Global variables are another solution, I think, but I would have way too many variables to update. I think the advantage with global variables is that one could just insert a global variable in a subVI and not have to wire it up through the different subVI levels, which one would have to do (I think) with control references.
    Can you offer any advice?
    Thanks!

    Paul,
    The actual implementation of the solution is up to you. This is indeed a complex question.
    I would offer the following advice:
    On globals:
    Try to avoid them. I try to restrict the use of globals to unidirectional. If you have ever dealt with a race condition, you will know why. Mistakes are often made with globals, and they are quite apt to become the biggest source of bugs in a program, especially in one as large and/or complex as your appears to be. If you must use globals, try using a shift register, or LabVIEW 2 style global instead. Basically, you use an unitialized shift register with two (or more) cases: Read and Write. This prevents race conditions, but only if the VI is non reentrant. However, implementation is still difficult.
    Control References:
    I also have read and heard about control references. I have had much use for them, for controlling the appearance of controls and indicators (and decoratiopns too, I guess...). However, I would caution you on using them to pass data around. This violates dataflow in a big way, as you are passing around pointers, instead of data. I believe this is difficult to implement, and even more difficult to keep straight. I personally recommend using them only for attributes of FP components, not for passing data.
    So, what do I believe is the most elegant solution? I think a data server is your best bet. This is close to a LabVIEW 2 style global, but a little more active. Simply write all of your data into a subVI in any manner, a queue, a FIFO, LIFO, etc. Then, retrieve the data as desired. Buffering, queuing, etc are all handled by the data storage and retrieval subVI. It becomes sort of a small active database. The two sides (storage and retrieval) are independent of each other, and the code is all handled in the function. A basic version is a LIFO, Last In First Out, wherein the data is overwritten constantly. The data is then read by the reading VI, the front panel VI in your case, at any time, and the data is always the latest. You can add complexity as you need, such as making it a FIFO. This is done by simply writing the data to an array, then reading back the oldest value (by reversing the array and reading index 0.)
    I believe this is an elegant solution to your problem. It does maintain dataflow, except that time is taken out of the equation, depending on how you look at it. It simplifies your program because you only need to do three things. Write the data handler, then drop in the function into the VI that writes, and the one that reads. It is also flexible in handling the data.
    Good luck, and let us all know how you do.

  • Using Excel with Visual C++ 6.0 (need a graph control that behaves as much like the one in CVI as possible)

    I hate to beat this to death but I was unable to find a
    clear answer to this question.  Does NI provide Excel control from within
    Visual C++ 6.0? 
    I read that NI supports the ANSI-C library only for Visual C++ 6.0 users:
    Thread : "Re: Benifits of using measurment
    studio for VC++ 6.0?"
    NI REP : drohacek
    Quote  : "we made the decision to support Visual
    C++ 6.0 users only through the ANSI-C interface and not through the Measurement
    Studio MFC-based class libraries."
    If there is a suggested way of controlling Excel from within Measurement Studio
    for Visual C++ 6.0 then I’d love to know it. 
    If not, can a plain statement be made basically stating that if you want
    to control Excel you can’t use a Visual C++ 6.0 environment even with Measurement
    Studio support?
    With .NET of course you can just decide to have Excel support added during
    project creation.  CVI can act as an ActiveX server and easily control
    Excel just by building off the examples shipped with CVI.  I see that
    there is support, using the Measurement Studio for Visual C++ 6.0 Project Wizard,
    for taking existing CVI projects and converting them to Visual C++ 6.0 projects
    or for calling CVI libraries from a .dll from within Visual C++ 6.0.  I suppose I could do the work
    in CVI and then convert the project but I'm so deeply tied into all my MFC calls that I don't see
    how I can cleanly include the CVI libraries into my existing VC++ 6.0 projects.
    What I'm really after here is a visual graph control like the one in CVI that I
    can use from Visual C++ 6.0.  I purchased a 3rd party graph control for use
    in VC++ 6.0 that works well but isn't really visual.  I mean you can't
    enter any values in it until you run the program and fill it out programmatically. 
    Then you can see which columns are two narrow, quit the program, adjust the
    column width of your now empty control, and repeat, until you get the thing
    looking the way you want.  If I could call into Excel from within Visual
    C++ 6.0  the way I do from within .NET
    then I could use Excel to hold the table and just read in the values into my table
    control at run time.  Basically I'd use Excel as a visual development tool
    for all my tables.
    I do all my coding from within CVI and Measurement Studio for Visual C++
    6.0.  I'd use CVI for everything if I didn't depend so heavily on certain
    outside controlled C++ .dll's.  Could you please suggest then what I can
    do to get Excel support for Visual C++ 6.0?
    Last question :
    Is there any plan to ever have a NI table control like the CVI table control for
    use in Visual Studio?  One that you can
    completely set up before you do any compiling? 
    I imagine that the way Microsoft sets up their environment makes this idea impossible.  Otherwise someone would
    have come up with a truly “visual” table control before now.
    Thanks,
    Grant
    Grant M. Johnson
    Project Engineer
    LECO Corporation

    Hello Grant
    You can most certainly use Excel with VC++ 6.0. Measurement Studio won't provided you with any classes to talk to Excel in VC++ 6.0. This is because Excel allows control via Automation and you can use its automation API to do anything you need with Excel. This is what CVI uses as well.
    You can see this MSDN article on how to set this up. This mentions VC.NET, but it should work the same way.
    Here is one that talks about VC 6.0 and Excel.
    Here is a code project article about this.
    Even with .NET, you have to do thru the Excel Automation support. Excel started shipping with Primary Interop Assemblies (PIA) which are .NET wrappers about the Excel Automation object model. C++ Automation is definetely not as nice as .NET, BTW
    See this document for more information about the Excel object model.
    I would not recommend using the CVI Excel libraries if all you want to use them for is Excel automation. You will end up creating un-necessary dependencies and go through extra layers that way. You can make calls straight to Excel from VC++ without requiring CVI.
    One quick observation about your excel approach. If you decide to use Excel as your table, you might be requiring everyone who uses your application to have Excel installed on their machines. Just wanted to make sure this was acceptable to you.
    Have you looked at the Datagrid Activex control, which is one of the common controls that ships with Visual Studio? You can add it to Visual Studio by right-clicking and picking it from the list of installed activex control. If you have not already, you should check it out.
    Microsoft has made significant improvements in the number of controls they provide with .NET. They have a Datagrid control that seems to be what you need.
    Measurement Studio did add some high level classes for Excel and Word Automation that simplify some common tasks, but these exists for VS 2003 C++ and VS 2005 C++, not for VC 6.0. Underneath, we end up using the same Excel automation classes, so you can easily setup something similar for VC 6.0. Plus you can find alot of references online on how to use the Excel Automation object model with C++.
    We currently have no plans in Measurement Studio to create a table control unfortunately. I am assuming when you said graph, you actually meant table, since Measurement Studio already  provides a ActiveX graph controls for VC++ 6.0 that is very similar to the CVI graph.
    On a side note, VC++ 6.0 is really really old. Have you considered upgrading?
    To summarize
    - Yes, you can use Excel with Vc++ 6.0 without mstudio.
    - Try using the Datagrid Activex control if you just need a table.
    - Measurement Studio provides high-level excel and word classes for VC++ 6.0
    - Measurement Studio provides a graph control for VC++ 6.0 which is very similar to the CVI graph.
    - Measuremnt Studio does not have a table control.
    - VC++ 6.0 is really really old. Have you considered upgrading?
    Bilal Durrani
    NI

  • Get All Controls References

    Hi all
    If somebody know how can i get all controls references of VI (including controls that founds in Tabs and Clusters). I need generic method, because i haven't information about VI (reference to VI i get only at run-time).
    Thanks, Nadav

    To include the controls on Tabs, pass the array from my previous answer into a for loop, use auto-indexing. Place a Class Specifier Constant in the loop, right click on it and set it's type to a Tab Control. Place a "To More Specific Class" function below the constant, and wire the constant into the top.
    If the control from the array that you pass in is a Tab Control, "To More Specific Class" will NOT return an error. Use a case statement and use the No Error case to expose the Tab Control properties. Return the "Pages" property (an array) and pass this into a for loop. Connect a property node to the indexed pages, then select Controls On Page to return an array of controls ON EACH PAGE. You need to set up a shift register and use build array to return all of the controls from all of the pages. Make sure you close the Page Reference.  You can concatenate the array of Tab Control Page items with your original FP Controls.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • Custom Waveform or XY Graph Control

    Hi
    I need a special Waveform Graph or XY-Graph Control in LV2009
    Take a look at the following picture or attachment.
    There are 12 channels and all channels have same X-axis (actually Time Axis)
    But each channel has different and "separate"  Y-axis (Amplitude)
    Is it possible to make it in LV2009? or LabVIEW has already something like that?
    Sorry for my bad english !
    Solved!
    Go to Solution.
    Attachments:
    CGraph.PNG ‏35 KB

    Ah, here we go. Use the "Active Plot" property and then set the "Y Scale Index" for each active plot.
    (Due to the way snippets work, the reference became a control.)
    Also, for your application, you probably want to put it in a loop that runs through all 15 plots:

  • Getting control references which are in tabs

    Hello,
    In a labview vi, we can successfully get all the control references, including references to tab controls.  We would also like to get at the control references of controls which are contained within the tabs.  We've been hunting around the methods/properties of the vi pane references (where we found the controls[]) reference, and can't seem to find how to access the control references within tabs.  Does anyone know the method/property to do this?
    Thanks
    David Jenkinson

    The Pages property will return a 1D array of references to each page. Then you can autoindex this to get the controls for each page reference:

  • Create static references array

    Hello,
    i have done a labview program which controls six different test machines.
    the different tests are VIs which are kept by the main program in an array of static references. this way i have to write the vi only once. afterwards i create six different references of the same vi, each of them managing one test machine.
    everything is working fine. the only drawback I have found, is how to create the six references of each VI.
    the first thing I tried, was to locate the static reference function inside a loop. I enabled indexing, and i expected to obtain an array of six different references of the same vi. unfortunately this is not working: i obtain an array with six times the same reference.
    to fix this, i located the static reference function inside a switch with six cases. all of this, inside the same loop. i have to use the static reference function six times, one for each test machine. this is working, but is more work. everytime a add a new test vi, I have to add the switch with the six cases. it is a lot of copy & paste work, and errors are likely to be done doing this.
    I would like to know if there is any other (and simpler) way of obtaining this array.
    enclosed you find an example showing this: the upper loop creates an array of six references but all of them are the same. the other one, uses a switch-case so that different references are generated.
    thank you in advance
    Attachments:
    static references array.zip ‏11 KB

    I think you missed the point of what I was getting at. If you create a template VI and programmatically open a reference to it 6 times you will get references to 6 independent instances of the template all running in memory. Nothing needs to get saved to disk. If the template changes simply close the 6 old references and open 6 new ones.
    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

  • Closing control[] reference

    If I have a main VI that calls sub-VI's, and I pass the control[] refereces of the controls in the main VI to the sub-VI. Should I use a for loop to close the control[] reference? And should I close the control[] referece in the main VI or the sub-VI?

    My understanding of what you are doing is building an array of the control references in the main vi to pass to the sub-vis. Is this correct? If so, why not bundle the references instead? This way you could easily pull out the required reference by name.
    Aside from that, if you are passing references to the front panel objects you shouldn't need to close them at all. The following links should be useful in helping you to understand when to close references:
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=506500000008000000834C0000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=closing+references&USEARCHCONTEXT_QUESTION_S=0
    http://www.ni.com/devzone/lvzone/dr_vi_archived4.htm
    Hope that helps.
    John

  • Advanced ?? Control Reference Update - Too slow.

    I have a main VI which controls a bunch of SubVIs. Each of these subVIs
    get data from the DAq and generate the plots and intensity graphs. I
    use a control reference to display these plots and graphs on my main
    VI. This is really slow. When I compare the speed at which the main VI
    is updated and the subVI is updated, there is a significant difference.
    Is this usually the case or am i missing something ?
    Thx
    Kudos always welcome for helpful posts

    I agree with tst, your PP VI runs at unlimited speed for no good reason. You should pace it with a small delay so it will release the control to other processes after each iteration.
    Also your DAQ part seems inefficient. Why do you configure the DAQ task from scratch, acquire, and close at every iteration? This is way too much work. You should flatten this out to the PP vi. Configure outside the loop on the left and close outside the loop on the right. Place only the ACQ part inside the loop.
    Also, place the real terminal of the graph inside the loop and clear it once at the beginning using a local variable. A local variable is always more expensive and less efficient.
    I don't understand why you need a timeout event in the main VI, it does not do anything except spin the loop, right? Just delete the timeout event.
    LabVIEW Champion . Do more with less code and in less time .

  • 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

  • Graph control causes general protection fault when changing axis range (64bit)

    Hello,
    i wrote a 32bit application which i'm porting to 64bit now and stumbled across a problem with the graph control.
    The Graph axsis are set to editable so that the user can change the axis range manually at runtime. The 32bit version has no problem here, but the 64bit  version is crashing  with a general protection fault at the source line with RunUserInterface().
    Is there a compiler option/value or something i should be aware of when swithing to 64bit that should be set?
    Or is this just a problem with the code of the control?
    I tried it with LabWindows v13.0.2 (278)  and v13.0.1, running under Windows 7 64bit.
    Thanks.

    Hello, danouj!
    Thank you for reporting this issue to us!
    However, information you provided is still unsufficient for us to determine the background of this bug.
    Please also provide the following details, so that we can identify the issue and investigate whether a workaround for this problem exists:
    From my understanding, when porting the application to 64-bit, you also performed some code changes to your CVI application. What are these code changes?
    If you run the 64-bit version of your application without these code changes, does the application also crash?
    What is the address of this crash?
    It would also be very useful, if you can send us a copy of a minimal snapshot of your project application, in which the problem still occurs, for us to investigate the issue.
    You can upload the sources at ftp://ftp.natinst.com/incoming
    Best regards,
    - Johannes

Maybe you are looking for