Search in an array of cluster

Hi!
Is there a smart way to search in an array of clusters.
For example: You have an array of a cluster with a digital control and a string control.
And you want to search for a specific value in the digital control.
What is the best way to that?
Is there a way, instead of a foor-loop and unbundle, like search 1-D array where you can ignore the string value.
If I use the search function I need to specify both the numeric and the string, but I'm only intrested in the numeric.

If you are always wanting to search this array based on the value of one particular value in the cluster, something you can do is when creating the cluster array, create two arrays that relate to each other on an element-by-element basis.
One array contains the values that you are going to want to search. The other array contains a cluster with all the other values. Searching the "key" array gives you an index that you can use to index the correct element from the other data array.
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

Similar Messages

  • Array of cluster to array of element - or - Cluster of arrays?

    Hi all,
    I have a large cluster (lets call it C_data) containing measured data e.g. 10 Temperatures, Pressure, (Temp_1, ...).....
    All these data are measured once per second. I now collect all data
    measured over a certain time in an array of the aforementioned cluster,
    that is
    an array of C_data. In order to display time series of data in graphs I
    need to extract arrays of elements from this array of C_data.
    In a text based programming language this could look like the following:
    Struct C_data {Temp_1, Temp_2, P_1.....}
    ar_C_data is an array of C_data
    now I want to do something like:
    array_of_Temp_1 = ar_C_data[*].Temp_1
    In some programming languages this works but I cannot unbundle_by_name the array of Temp_1 from ar_data in Labview.
    Since my cluster is large and may change in structure (for this reason I use a typedef) a generic solution would be the best.
    I know that I could: loop over all elements of ar_C_data, unbundle by
    name, index elements into arrays, and use these but this seems very
    inefficient if it is done every second on a large cluster (30 elements) with several thousand array elements....
    Olaf

    You can minimize the overhead of scanning through all elements and extracting if you pre-define the array and use "replace array subset".  This avoide having to re-size the array which is costly.
    Or you can keep an array separately in memory.  When one cluster element is added, the corresponding element is added to the array too.  Causes some memory overhead, but you're going to have that anyway if you generate them "on the fly".
    I don't see a way to do this other than either search through the array and pick the elements you need -or-
    keep a copy of the data in a form you can use.
    It's a common question of how to structure data to best suit two sometimes conflicting needs - efficiency and useability.
    What might be of interest is to change the "Array" - "Cluster" order and have a single cluster C-Data with arrays of each element required.  Might be a bit more difficult to use, it depends on your application.
    This way you have all arrays ready at all times, but generating a single cluster requires bundling the individual units on the fly.
    Shane.
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)

  • 1D Array of Cluster of 2 Elements Write to Spreadshee​t

    Hi all, first time using LabView in many years.  I am trying to write a VI that will acquire data from our cDAQ (right now just trying to get it to work with a single thermocouple in a NI 9211, but eventually will be 8 X thermocouple, 4 X pressure transducer), display it in realtime on a plot, and then when the acquisition is stopped, output the data to a file for later use.  I am currently using the Base LabView package.
    My problem (as I remember it was 7 years ago when I last used this) is with the data types not working together.  This is my thought process currently on building this VI.  Everything is inside a While Loop with the Wait function at 1000ms.
    - Acquire a point of data using the DAQ assistant
    - Send that point of data into a bundle
    - Send the iteration count into the same bundle (as a timestamp)
    - Send the resulting cluster of 2 elements into a Build Array function
    - Send the resulting 1D array to a shift register in the While Loop, as well as to an XY graph for realtime plotting
    - Wire the incoming point on the shift register back into the Build Array function
    In my mind, this allows the XY graph to plot the complete array every iteration, giving a realtime view of the signal.  Everything works fine up to this point.  My problems are:
    When I stop and restart the program, the shift register is not cleared, so the existing data in the array remains on the graph.  I know I need to initialize the shift register to clear it, but I cannot figure out what to wire to it that will be compatible with the data type (I just get broken wires with everything I tried).
    Similarly, I cannot figure out how to output this data to a spreadsheet after I Stop the While Loop.  I think I should wire the "Write to Spreadsheet File" VI to the outgoing shift register, but again, I can't get compatibility with data types (source is a 1D array of cluster of 2 elements).
    I have attached my current program "Production" to this post.
    I look forward to the help!
    Brad
    Attachments:
    Production.vi ‏46 KB

    Hi Brad,
    I would suggest you change your architecture. First, to answer your questions:
    1.
    In order to ensure that your shift register is not reading the last
    value from it's memory location, you just need to create a constant for
    the shift register. To do this, right-click at the input of the
    'left-placed' shift register and create a constant.
    2. The Write
    to Spreadsheet is expecting a 1-d or 2-d array while you are wiring a
    Dynamic Data Type. Use the Convert from Dynamic Data Type to convert
    the data into the appropriate waveform after which you can get the
    waveform attributes which includes the values and the timestamp data. Or, you can use the Write to Measurement File to write to a .lvm file which can be opened in Excel as well.
    Changes to your architecture:
    Since
    you are using a lot of channels, I would advise you use a
    producer/consumer architecture. You can have a look at this
    architecture by navigating to File -> New.. and searching for the
    Producer/Consumer template. You will notice that this architecture uses
    queues. The way you will design your VI is to use DAQ to acquire the
    data into your producer loop, convert this data into a waveform and
    then send this data to the consumer loop via queues. In your consumer
    loop, you can write this data to a file. At this point, I would
    encourage you to write to a binary file instead of a spreadsheet file. The write will happen faster and you will be using less space on your hard disk when compared to ASCII writes.
    I know this can be real confusing for a beginner, so be sure to post back if you have any questions.
    Adnan Zafar
    Certified LabVIEW Architect
    Coleman Technologies

  • Array to cluster with adjustable cluster size

    Hi all
    Here I have  a dynamic 1D array and I need to convert it into cluster. So I use Array to Cluster function. But I notice that the cluster size is a fix value. How can I adjust the cluster size according to the 1D array size?
    Anyone pls give advise..
    Thanks....

    I won't disagree with any of the previous posters, but would point out a conversion technique I just recently tried and found to work well for my own particular purposes.  I've given the method a pretty good workout and not found any obvious flaws yet, but can't 100% guarantee the behavior in all settings.
    Anyhow, I've got a fairly good sized project that includes quite a few similar but distinct clusters of booleans.  Each has been turned into a typedef, complete with logical names for each cluster element.  For some of the data processing I do, I need to iterate over each boolean element in a cluster, do some evaluations, and generate an output boolean cluster.  I first structured the code to use the "Cluster to Array" primitive, then auto-index over the resulting array of booleans, perform the evaluations and auto-index an output array-of-booleans, then finally convert back using the "Array to Cluster" primitive.  I, too, was kinda bothered by having to hardcode cluster sizes in there...
    I found I could instead use the "Typecast" primitive to convert the output array back to my cluster.  I simply fed the input cluster into the middle terminal to defin! the datatype.  Then the output cluster is automatically the right size and right datatype.
    This still is NOT an adjustable cluster size, but it had the following benefits:
    1. If the size of my typedef'ed cluster changes during development by adding or removing boolean elements, none of the code breaks!  I don't have to go searching through my code for all the "Array to Cluster" primitives, identifying the ones I need to inspect, and then manually changing the cluster size on them one at a time!
    2. Some of my processing functions were quite similar to one another.  This method allowed me to largely reuse code.  I merely had to replace the input and output clusters with the appropriate new typedef.  Again, no hardcoded cluster sizes hidden in "Array to Cluster" primitives, and no broken code.
    Dunno if your situation is similar, but it gave me something similar to auto-sizing at programming time.  (You should test the behavior when you feed arrays of the wrong size into the "Typecast" primitive.  It worked for my app's needs, but you should make sure it's right for yours.)
    -Kevin P.

  • How do I convert a 1-D array of cluster of 5 elements into a 2-D array of numbers? (history data from a chart)

    Hello,
    in my vi I have a chart with 5 Plots displaying measurement data.
    The user should be able to save all the history data from the chart at anytime. (e.g. the user watches the chart and some event happens, then he presses a "save"-button)
    I know, that I can read out the history data with a property node. That is not the problem. The problem is, how do I handle the data? The type of the history data is a 1-D array of cluster of 5 elements.
    I have to convert that data somehow into a 2 D-array of numbers or strings, so that I can easily save it in a text-file.
    How do I convert a 1-D array of cluster of 5 elements into a 2-D array of numbers?
    I use LabVIEW 7.1
    Johannes
    Greetings Johannes
    Using LabVIEW 7.1 and 2009 recently
    Solved!
    Go to Solution.

    Gerd,
    thank you for the quick response and the easy solution.
    Look what I did in the meantime. I solved the problem too, but muuuch more complicate :-)
    And I have converted the numbers to strings, so that I can easily write them into a spreasheet file.
    Johannes
    Message Edited by johanneshoer on 04-28-2009 10:39 AM
    Greetings Johannes
    Using LabVIEW 7.1 and 2009 recently
    Attachments:
    SaveChartHistory.JPG ‏57 KB
    SaveChartHistory.JPG ‏57 KB

  • Array of cluster

    Hello,
    i'm using array of cluster to allow user entering differents setting
    But in some case i would like to adapt viewing to hide  some parameters or displaying 0 or a null field
    my problem is when creating a ref on control in the list how to know wich line is concerned to modify the good one
    here a vi for example
    when case 1 is seleced in first column other ctl can be any of  choices
    when case 2 is selected i would like the mofify two others to be 0 and none
    is there an other way than playing with coordonate and size of elements to know which line is the current one ?
    Regards
    Tinnitus
    CLAD / Labview 2011, Win Xp
    Mission d'une semaine- à plusieurs mois laissez moi un MP...
    RP et Midi-pyrénées .Km+++ si possibilité de télétravail
    Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
    Don't forget to valid a good answer / pensez à valider une réponse correcte
    Solved!
    Go to Solution.
    Attachments:
    list of ctl.vi ‏8 KB

    I was able to simplify that VI to the point where I can post the code to demonstrate the idea.  Here it is in both 8.6 and 9 (it seems to have lost some font formatting when saving back to 8.6).  I haven't used XControls at all but it seems like the sort of thing that could be converted to one easily if I had the time and need for it.
    Attachments:
    Array of Clusters in Table.vi ‏52 KB
    Array of Clusters in Table 8.6.vi ‏33 KB

  • Array of Cluster with event structure

    Hi,
    I am having Array of cluster with cluster having 1 String Control , 1 Combo box, 1 Led control and 2 Numeric control. In the combo box i am having two options to select ('Binary' and 'PWM').Whenever Binary is selected then Led control has be enabled and whenever PWM is selected 2 Numeric control has to be enabled.
    Is there any way to do this??
    Pleas help me...
    Regards
    Meenatchi

    actually in my application, the front panel has to have 16 rows of controls (1 string control, 1 combo box, 1 Led control, 2 numeric control).so i planned to keep all those controls in a cluster and create one array.If i didnt so i will have 16x5 controls in my front panel and i have to put 16 event cases for each combo box to do the enable and disable of controls..
    is there any simple way to do this..i have attached my front panel view
    Attachments:
    Untitled10.vi ‏139 KB

  • Search 1-D Array not working

    Hi all,
    Can anyone help me with the attached VI?  The "Search 1-D Array" does not seem to be searching.  The output is always -1, when I know that my data from my excel sheet that I am reading from contains the number 193.3359.  I intend to find how many rows in my excel data contains the number 193.3359, and I would like an output array to copy each row & all it's info.  (example: if there were 6 rows that contain the number 193.3359, i would like all 6 rows show up in the output array).
    Thank you for your help.  I do not have a sample of my data, but it's about 2,000 rows and 10 columns.  They contain numbers & words.  Here I am just searching for a number.
    Attachments:
    Search Excel Data.vi ‏12 KB

    Taki1999 wrote:
    I'm guessing that you have a precision issue.
    Are you sure that the number is coming back as 193.3359 and not 193.335899999?
    No, he's searching for raw strings so this cannot be it. This would be an issues with e.g. DBLs
    Some other guesses:
    The strings in the array elements contain leading or trailing spaces or other nonprintable characters.
    The file has comma as decimal seperator (e.g. from a german computer).
    LabVIEW Champion . Do more with less code and in less time .

  • Array to Cluster, Automate cluster size?

    I often use the Array to Cluster VI to quickly change an array of data into a cluster of data that I can then connect to a Waveform Chart.  Sometimes the number of plots can be different which results in extra plots (full of zeros) on the graph, or missing plots if the array is larger than the current cluster size.  I know I can right-click on the node and set the cluster size (up to 256) manually.  I could also use a case structure with as many Array to Cluster nodes as I need, set them individually and wire an Array Size to the case structure selector but that's kind of a PITA. 
    My question is whether or not anyone knows a way to control the cluster size value programatically.  It seems that if I can right-click it and do it manually there must be some way to automate it but I sure can't figure it out.  It would be nice if you could simply wire your desired value right into an optional input on the node itself.  Any ideas will be much appreciated.
    Using LabVIEW: 7.1.1, 8.5.1 & 2013
    Solved!
    Go to Solution.

    I'm under the impression it's impossible.  See this idea for related discussion.
    Tim Elsey
    LabVIEW 2010, 2012
    Certified LabVIEW Architect

  • Add element to array of cluster

    I have an array of cluster. Cluster contains two elements. How to add an element in cluster at run time on the second position efficiently? In other words dont want another copy of cluster which contains three elements and copy the original two elements plus the new element. 
    Original array of cluster lets say has two element Temp1 and Pressure 1.
    Need to add another element in cluster and now the array of cluster will be Temp1, Volt1 and Pressure 1. So Volt 1 is added to all cluster elements at second order throughout the array of clusters programatically. 
    CLD,CTD
    Attachments:
    TestAddElementToCluster.vi ‏10 KB

    It is unclear from your original post what the problem you need to solve actually is.  Are you trying to create a user interface?  Do you need to dynamically add arbitrary data to a data set, or is it a fixed set of functionality that can be dynamically changed in predetermined ways?
    Having done it, I will recommend you not try the scripting and subpanels approach.  There are almost always better ways.
    Remember that your data structures do not need to mirror your user interface.  If you were trying to display the temperature, voltage, and pressure data to the user, a multicolumn listbox may be more appropriate than a raw cluster in an array.  Internally, this would allow you to maintain the temperature, voltage, and pressure as separate arrays and only display the ones you want in the listbox.
    Please give us a more information on the problem so we can help you with an easier solution.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • Add elelment by element in an array of cluster

    Hi All,
    I have a problem in extracting data from array of cluster to a single cluster. Please have a look at the attachment.I have found the solution but it consumes lot of memory because of shif registers andi am using this many places which is loading to nearly 100% in RT. Please provide an better alternative solution.
    Attachments:
    Array of Clusters.JPG ‏153 KB

    AutoTEC wrote:
    Hi,
    No i am almost at the end of coding . If i change the entire architecture affects. Only problem is this logic consumes more time. Pls any other idea...
    Standard situation if a propper data management is not done before coding OR  lead to the wrong architekture.
    Do you use type definitions? Help a lot to avoid the horror of optimizing the datastructure.
    Since it is much faster to rebuild a cluster by indexing the elements from your cluster of arrays than generating a cluster  of arrays from an array of cluster (Puh!) 
    AND you have timing problems I see only two solutions : Faster hardware or a reorganisation of your data.
    So change the datasturcture , create a subvi 'IndexMyData2Cluster' and whereever you indexed the array of cluster  replace it with that vi.
    Or run both structures in parrallel (BRRR, race conditions, inconsistent data , uuuaaahhh)
    Greetings from Germany
    Henrik
    LV since v3.1
    “ground” is a convenient fantasy
    '˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'

  • Programmatically Change Array to Cluster Size

    Hello,
    I have a Chart with several values scrolling across it. The number of
    values is variable. To prepare the data for the Chart, I use the Array to
    Cluster element. Is there a way I can programmatically change the size of
    the cluster output?
    Thanks,
    Peter

    Peter,
    As far as I know, you cannot programatically chage the size of the cluster output in the Array to Cluster vi. However, you may not need to convert to a cluster for charting. The chart will take a 2D array and plot mutiple lines. See the attached example which uses Reshape Array to form the data for a chart.
    The only hitch is that it erases the plot when you change the number of values to plot. This may or may not be important to you.
    Tim
    Attachments:
    Reshape_array_for_chart.vi ‏18 KB

  • Boolean LED Blinking in Array of Cluster

    Hello,
    I did not found anything to my problem in the developer zone of ni.com. Only how to index a element in an array of cluster.
    I want to set the Property "Blinking" of a boolean LED control in an array of cluster. But all attemps were to no avail and nothing happens.
    Can someone look at my VI please?
    Thanks shavo
    Message Edited by shavo on 05-28-2009 05:12 AM
    Attachments:
    ClusterBlinking.vi ‏58 KB

    It's not possible to change the physical property of the element of a array of cluster.
    Balaji PK (CLA)
    Ever tried. Ever failed. No matter. Try again. Fail again. Fail better
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.

  • Use of Write Key VI with an array of cluster

    Hi,
    I wanted to use an array of clusters to define some configuration parameters for an application. Unfortunately, "Write Key VI" doesn't support the cluster type. Has anybody modified this function ("Write Key VI") to support cluster and array of cluster? If not, any clue to keep it as simple as possible?
    My clusters include boolean, path, U32 and string.
    Thank you,
    Olivier 
    Solved!
    Go to Solution.

    OD wrote:
    Couldn't log to this website. Any alternative ?
    Sure see this Nugget.
    I have links for other methods included but the Nugget does exactly what you are asking to do. I wrote th Nugget to entertain other developers, but in the end is serves as an example why you may want to find another approach. You'll understand what I mean once you look at that Nugget.
    Parapharisng from Jurrasic Park "Just because could do something does not mean we should."
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Search in object array

    I am working on a program in which one of the problems is to search an object array to allow a user to edit an item in the array. I have examples on how to do linear and binary searches, but they are all simple strings of numeric data. How do I apply this algorithm to a more complex array?I have a class file called Application that contains my constructor, and my get & set methods for creating the objects in the array. And I have a driver class to allow a user to view the array, add items to it , and edit items in it.
    This is an example of my declaration of the initial items:
    Application inventory[] = new Application[100];
      inventory[0] = new Application("Jumpstart Toddlers", 14.99, 500);
      inventory[1] = new Application("Norton Antivirus 2003", 49.99, 1200);
      etc....
    I would like to set it up so that the user is prompted for the name of the software item they would like to edit, the array is searched using a method which returns the index the name was found in.

    Sounds like a homework assignment to me but...
    Appliction apps[] = new Application[100];
    ...Add Items to the apps array...
    String software_to_search_for = .. user entered
    data....
    for (int i = 0; i < apps.length; ++i)
    if
    f
    (apps.getSoftware().equalsIgnoreCase(software_to_sea
    ch_for))
    edit(apps[i], software_to_search_for);
    public void edit(Application app, String newName)
    // You can do anything here
    app.setName(newName);
    } // edit
    True enough, this is an assignment. But..These assignments were given to us without all the necessary tools. They are set up by the dept. and we have to finish them even if the instructor does not finish covering all the relevant material.In this case, we have not covered the equalsIgnoreCase(something obviously necessary for my problem). Now that I know what I am looking for, I have found it in my book and can apply it to my code appropriately. I was not necessarily looking for code, just the tools I need for my own design. This is something that the Computer dept. allows for in that they have assistants in the open labs that will help in this manner. Problem is, everyone has been out for Thanksgiving since Tues. Please dont feel as though you assisted someone in cheating!! I can assure you, that is not the case here. Thank you for your help.

Maybe you are looking for

  • What network is best for Wi-fi connection? and why do I need Wi-fi?

    i got a msg for updates for my iphone and tells me I need to have wi-fi for these updates. I need help, not good at this tech stuff

  • Short dump while scheduling infopackage

    Hi, im getting short dump while scheduling infopackage  for( 0cfm_init_positions )as it is giving  dump like MESSAGE_TYPE_X runtime error in BI test system but in dev it's working fine if anybody knows how to resolve??.

  • Pages to PDF export and text not showing

    I exported a pages document from Pages to PDF and I can not see the text??? Font is Tex Gyre Adventor and it is in the color white with a shadow and a tangerine box backdrop Thoughts? - Thanks!!

  • Nokia 5220 WHITE SCREEN PROBLEM *HELP*

    hello guys ... my phone's (5220) screen has gone White ... !! i have absolutely no idea what the problem is ! i took out the battery and put it back again .. but when i turn it on ..after the nokia logo the screen goes white again !! i cant do anythi

  • Password protect site for a group

    Is it possible to password protect an iWeb site for a group of people, so each user can create and select a unique username and password to enter the site? I am sure that I would need a 3rd party application to do this, but does anyone have any sugge