Jump to content

"Strings and Value[]"-Array


ichsw

Recommended Posts

Hi everybody,

I have a problem with a ring-control in my labview program.

The ring has many items (65536) and non-sequential values.

I need to find the actual index of the ring array and set a new calculated index afterwards.

As I couldn't find a way to get the actual index directly, I started a for loop and compared every "Strings[]"-array element with the "Ringtext.Text"-property. So far, so good.

But when I want to set a new index to the ring, I need to use the "Set Value"-property.

Here comes the problem: Every time I use the "String and Value[]"-property to get the index corresponding value, labview needs about 10 seconds to build it. Why is that? Labview doesn't have problems building the "Strings[]"-Array.

Is there a way to handle the ring index seperatly I couldn't find?

Can the "Strings and Values[]" operation be accelerated?

Thank you for your time and your ideas.

Best,

ichsw

Link to comment

...The ring has many items (65536) and non-sequential values...

...labview needs about 10 seconds to build it. Why is that?...

I think you really should consider another approach; the Ring control is a UI element, and is not intended for data storage.

Without knowing the exact layout of your system, I would recommend that you use a LV2 global or something similar to hold your values instead.

/J

Link to comment

Got you...I know about the seperation of data and view (mvc) in object oriented programming. But I thought labview does this itself with the controls and indicators. When I use the LV2 solution, I have to synchronize the gui and the data elements all the time, right?

I think, it's a good idea to describe why I need the index handling. Maybe you can suggest an approach that doesn't use the ring arrays.

I want to change the standard behavior of a ring, so it can be incremented/decremented with the up/down-keys and does not overflow and underflow. Therefor I have to filter the key event and check if the increment/decrement is allowed.

Remeber that the values are non-sequential.

I figure it's not a good idea to change the behavior of a standard labview element, but I really need to implement this function.

What about creating a whole new control? Does anyone has experience with that?

Any ideas welcome.

Best,

ichsw

Link to comment

Yes, you would have to synchronize your LV2 with your FP control/indicator. Likely the biggest slowdown you're facing is that operating on controls/indicators can only work in the UI thread, while most code can work (often in parallel) in various other threads.

I vaguely recall someone posting about doing something like that before; at least related to not wrapping. An XControl would provide the encapsulation you need, I think, but XControls are not necessarily for the faint of heart.

Are the value non-sequential AND non-contiguous, or just non-sequential? If it's the former, play with values in the unassigned spaces between values and see how it handles coercion.

neil does beg a good question, however - seems like an awful lot to dig through for a user. Maybe it could be broken down into three or four separate rings and selected in stages (e.g., the Add A Vehicle pane on advanceautoparts.com)

Link to comment

Like Neil and asbo already explained, it was the usability of a 65000 element Ring control that bothered me the most.

I really thought you just used the ring control to have an easy lookup between non sequential values.

Some ideas if you still want the user to go through all these key presses;

* Put your sting-value pairs in an array of clusters, and keep track of the current index. When user presses the Up/Down Keys, move index accordingly and update UI

* create an xControl and store the string-values array within the xControl data

If possible, I really think you should post an example showing how this should work.

Question; do you want to be able to find a specific value given a string, or do you want to get the string that is associated with a given value.

/J

PS. The thread I believe asbo is relating to is this;

http://lavag.org/top...8757#entry98757

This deals with preventing roll-over from min to max or vice versa.

  • Like 1
Link to comment

Thank you everybody for your help...

...but I don't have time to experiment any further because of that "little" feature.

I would have tried the xControl approach to implement my own control behavior, but I don't use the professional version of labview.

In general I would prefer a seperation of data and view, but it's too much work to change the main concept of the program I was ordered to adapt.

That's my solution:

I used the "Strings and Values[]"-property with every ring that doesn't have too much elements.

For the critical rings I build my own "Values[]"-array once at the beginning of the program. With the help of the "Strings[]"-property I can search the index and with the generated "Value[]"-array I can get the corresponding value.

Not nice, but it works.

Thank you for your time, again.

Best,

ichsw

Link to comment

When LV builds just the string array, you get the copy of the array stored by the ring control itself -- no copy is made unless/until you modify the array downstream. Since you are only searching the array, no copy gets made, so it seems fast. When you ask for the array of strings and values, we have to build you a whole new data structure including copying each individual string so that the new data structure is independent of the one in the ring (that's how dataflow works; it is not a bug or something for LV to fix someday). So you see a massive penalty hit.

You can maintain this data structure yourself, as various people have pointed out, in diagram local storage, like a shift register on your event loop (I wouldn't use an LV2-style global unless you really need this information elsewhere in your program and not just on the local diagram). Then, yes, when you make a change to one data structure, you make the same change to the other data structure.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By Mahbod Morshedi
      Hi All,
      I'm new to LabVIEW and overall programming. I wanted to use a combo box to extract the string and associated value to use later for calculation and presentation.
      I have come up with this one below, which works fine and is very modular (I can just add the solvent info, and it is good to go with no other change, unlike implementation as case structure). However, I wanted to know if this is good or is there a better (more straightforward) way to achieve the same thing?
      Cheers,
      Mahbod

    • By hooovahh
      View File Hooovahh Array VIMs
      Here is the Hooovahh Array VIMs.  This initial release contains 14 VIMs for manipulating array data, which are intended to replace OpenG functionality, but with the added benefit of data type propagation, and increased performance using newer array manipulation techniques.  In later versions other Array manipulation functions were added moving all the OpenG stuff to their own palette.
      Most of the OpenG functions are unchanged, but a few use the newer conditional and concatenating tunnels.  And a few functions have added performance based on other inputs.  For instance the Delete Array Elements can operate in a more efficient way if the input indexes are already sorted.  The Filter 1D array can also be more efficient if the input is known to not contain any duplicates.
      Because these packages contain VIMs, they require LabVIEW 2017 or newer.  Having these functions be VIMs mean all functions work with various array data types.  Included functions are:
      Conditional Auto-Indexing Tunnel Delete Elements from (1D or 2D) Array Filter 1D Array Index (1D or 2D) Array, Scalar, Row, Column Remove Duplicates from 1D Array Reorder (1D or 2D) Array Reverse 1D Array Slice 1D Array Sort (1D or 2D) Array Convert 1D to 2D Convert 2D to 1D Find Subarray Force Array Min/Max Size Foreign Key Sort Submitter hooovahh Submitted 10/11/2017 Category *Uncertified* LabVIEW Version 2018 License Type BSD (Most common)  
    • By hooovahh
      Here is the Hooovahh Array VIMs.  This initial release contains VIMs for manipulating array data, which are intended to replace OpenG functionality, but with the added benefit of data type propagation, and increased performance using newer array manipulation techniques.  In later versions other Array manipulation functions were added moving all the OpenG stuff to their own palette. 
      Version 2.0 changed the suffix naming standard.  Updating may mean replacing calls to the new versions since the name on disk has changed.  This was for consistency and I'm sorry for breaking compatibility.  The added type defs in 2.0 may break compatibility too but these help avoid code breaking bugs since VIMs allowed any data type previously.
      Most of the OpenG functions are unchanged, but a few use the newer conditional and concatenating tunnels.  And a few functions have added performance based on other inputs.  For instance the Delete Array Elements can operate in a more efficient way if the input indexes are already sorted.  The Filter 1D array can also be more efficient if the input is known to not contain any duplicates.
      Because these packages contain VIMs, they require LabVIEW 2017 or newer.  Having these functions be VIMs mean all functions work with various array data types.  Included functions are:
      Conditional Auto-Indexing Tunnel Delete Elements from (1D or 2D) Array Filter 1D Array Index (1D or 2D) Array, Scalar, Row, Column Remove Duplicates from 1D Array Reorder (1D or 2D) Array Reverse 1D Array Slice 1D Array Sort (1D or 2D) Array Convert 1D to 2D Convert 2D to 1D Find Subarray Force Array Min/Max Size Foreign Key Sort
    • By WILSTi
      Hello,

      I'm developing an application to play "Battleship" with another opponent through serial communication. I currently have the following difficulty:
       I have not been able to fill the Array with my opponent's ships, I can modify a position, but by changing the position, the result of the previous position returns to its original value.
      VI operation:

      For my turn, using the radio buttons, I select the coordinate and press the SEND button. My opponent answers me with a 1 if I hit or with a 0 if I failed, this data is what I couldn't keep in the array.
      Best regards,
      3Q.vi
    • By Chen Li
      The program obtains the number of messages in the hardware buffer through ZCAN_GetReceiveNum function, and then calls ZCAN Receive to complete the received data. When the amount of data reaches 1000 frames / s, the program will crash.
      UINT ZCAN_Receive(CHANNEL_HANDLE channel_handle,  ZCAN_Receive_Data* pReceive,  UINT len,  INT wait_time = -1);

      I think there is something wrong with creating the parameter array ZCAN Receive Data* pReceive. Has anyone ever encountered a similar problem?
       
      Receive.zip
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.