Jump to content

working with values of a table


Recommended Posts

Hello everyone,

I have a question regarding re-writing values in a table.

I have a table (attached as png). I have to save and read the values from this table and main point re-write.

I have been able to save and read but whenever i try to re-write a value or give in a new value in the table, it turns all the other values to zero and only the new value(s) is then shown. Do you know how i can avoid that?

And one more thing i have used .ini to save the values. Is there any easier way to do so?

Thank you :)

 

table.PNG

Link to post

Seems to work for me.  There is quire a bit of inefficient ways of doing things, but the work of clicking Set Y or Set C does set the cell value leaving the rest.  Am I misunderstanding what it should do?

EDIT: Okay I see the problem.  So in case 1 of the sequence structure add a Transpose 2D array after the second build array, if you probe this you'll see the array only has two rows but 6 columns which is the opposite of what you want.  Then the next issue is in case 2 where every time the VI runs you are initializing the array (outside the sequence structure) be be empty.  What you probably want is to use a local variable on the WCS and wire it to the shift register in case 2.  Then the newly loaded (and transposed) values will be used and will be replaced when you click Set.

Link to post

Problem is not Setting the values. Problem is when i run the program and the saved values are read and I want to just  change one value or overwrite one value, all the other value changes to 0 and only that new value stays in the table and if i click okay only that value is saved (obviously) and when i re-run again only one value can be saved in the table (again, obviously).

What i want is to be able to overwrite the values without changing the rest of them. How can i do this?

Also, how can the user add new row from the front panel? for example G54.1 which automatically should be after G54.

Link to post

I found several other suggestions.

  • Control labels should be unique
  • Control terminal labels should always be seen.
  • Overuse of local variables
  • Use of native global which doesn't seen necessary here
  • Use of scalar data when you want it to grow as needed (meaning arrays should be used)
  • Use of sequence structure

Attached is a re-write that uses a state machine and no local or global variables.  For the saving and loading I highly recommend getting the OpenG Configuration File palette which allows saving any data time into an INI file, in this case I saved the Y C and Row Names.  I also added the Add button which makes a new row.  If you don't have the OpenG you can replace this with your own custom VIs that reads and write arrays of strings.

Subvi_WCS Hooovahh Edit2.vi

Link to post

could i please ask how many  years of experience do you have? :o Your program just seems so clean and easy to understand.

I would have never thought of openG, never worked with it.

Global variable is required because this is just a SubVI and Y and C has to be read from the main VI.

:thumbup1:

Link to post

Why thank you.  I've been using LabVIEW pretty much daily since college in 2004.  If you do anything that long, and that often, you get pretty good.  I often make the comparison to a welder.  If you started mig welding in 2004 your first welds probably look pretty terrible (just like my code).  But after doing it daily for 13 years you had better be pretty good.  Then there's the fact that I actually enjoy programming in LabVIEW so I seek out new techniques and keep up with the community.  Anyway enough about me.

OpenG is a fantastic set of tools that every developer should have available to them.  They are licensed under BSD which is a pretty relaxed license stating you can use it or modify it however you want, with only a few minor caveats.  The code has been used and tested since version 5 (or older), but hasn't had any major updates in a while.  Some of the most valuable are under File I/O, Array, and the Variant Configuration.  Having a single function that saves a front panel to a file, and loads a front panel from a file can be very useful.

Global variables aren't the only way to pass data around to other parts of the application.  Native globals have their place but often times a more manageable solution is to use a functional global variable, VIG, or action engine. 

http://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/m-p/503801#M240328

http://www.labviewing.com/fgv-in-labview/

http://forums.ni.com/t5/Example-Programs/Basic-Functional-Global-Variable-Example/ta-p/3503982

Like in this case I could see an action engine that has a Load, Save, Read, and Write method.  Other options for passing data can involve references like a queue, or in modern versions the channel wires.

Link to post

First of all thank you so much for the references although i might have to go through them more than once.

I need to learn a lotttt. It's been hardly one year since I began LabVIEW :rolleyes:

Thank you for your help, really appreciate it, though it makes me feel like i should just ask you all my doubts regarding the project and maybe give it to you to see how differently you would do it. :)

 

Link to post

Thanks but I don't know everything.  The community as a whole knows way more than just myself about the best ways to do things.  Post here, or at the NI forums if you have question about the pros and cons of solving a problem a particular way.

Link to post

Hi! I need your help again.

I still have a doubt regarding the table control. How can I work on the individual rows? For example i have values of Y and C for G57 and i want to avaoid selecting the rows every time. How do I select the row depending on the options like G54  and so on. The "G54-59" will be given by the user. After the value is given I have to read the values and also be able to save them.

Also it should be able to recognize if G54.1 (for example) is not there then it should automatically add a new row.

Thank you :)

Link to post

You already see how to work on individual rows.  What do you mean avoid selecting the rows every time?  Where in the code are you selecting rows at all?  If you want a given rows values search for it.  You see that the Add function already searches for Row Names that match the one you are trying to add, and you get an index of where the match is.  Index the Y and C values at that found index and you'll have the Y and C values for a given row.  If it returns -1 then there was no match.  This add also won't add a new name if the name already exists.

Link to post

Here is a program that uses a multi-column listbox instead of a table.  The selected row is highlighted, and the values in the row are output to the DBL indicators on the front panel.  Selecting a row updates the output values.   Using the "Set" buttons generates new values, and also updates the row selection. A cluster is used for the shift register data to clean up the diagram.  The diagram has a case structure with the "0" case handling the file read initialization.  The "0" case code should be placed in a subVI to get rid of the case structure, but I wanted to keep the code to a single VI.

Subvi_WCS_listbox.vi

Link to post

Here is yet another simplified version based on a classic listbox editor idea.  It has the following features:

  1. "Table" values are stored in a 2D DBL array.
  2. Editing is done using a multi-column listbox.
  3. DBL controls edit the individual row elements
  4.  Listbox updates when the DBL control values change
  5. DBL values are returned and table value file is updated when VI is closed. 

Subvi_WCS_listbox_classic.vi

Link to post

Here is an absolute minimalist version.  From what I understand of your question, what you really want is an dialog editor that loads a file into a table, allows the user to edit the table, and also allows the user to select a row and return the values from that row.  I have attached a file that does that using the "Editable Cells" feature of the multi-column listbox to allow direct editing of the table values.  You must triple-click a cell to edit it. The user can also select a row to return the values.

cells.png

 

 

Subvi_WCS_listbox_editable.vi

Edited by smarlow
Changed attached VI to simplify more
Link to post

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 Mike King
      Hi LAVAers.  I thought I'd post this up to grab some more eyes and ideas, and maybe contributors if there is interest.  I've started development of an open source datagridview project using .NET in LabVIEW to finally have a well implemented datagrid for use with LabVIEW UIs, data types and event integration.  I have this all working in a sample project and would love more ideas, feedback and and help if anyone wants to contribute.
       
      The project is hosted on github,  https://github.com/unipsycho/LabVIEWdotNetDataGrid
       
      I started a discussion for it in the LabVIEW NI community site when I started but its a LOT more presentable now, so extending this to LAVA.  The original discussion is here:
      https://forums.ni.com/t5/LabVIEW/OpenSource-Project-for-a-NET-Datagrid-for-LabVIEW/m-p/3194273
       
      The main premise of the project is to have extended data types, extended features with a event driven datagrid for LabVIEW using .NET.

       
      Please let me know what you think or if any questions or ideas to add to this.
    • By Colin Zhang
      Hi All,
       
      Which style TABLE control can support the direct input and selective input as same? or how to achieve this function?
      I have tried the Modern/Classic/System style Table, but can not find a way to achieve this goal. 
       
       
       
       

    • By cherold
      After getting pretty deep into an experimental control paradigm with a Table Control as the user interface, I've run into the very frustrating problem of slow formatting updates (cell background and text color). Even when deferring panel updates, formatting a 50 row by 200 column table based on each cell's string takes seconds. The UI table assists the user in generating a 2d string array, which is subsequently sent to a set of hardware objects to control a Bose-Einstein condensate experiment.
       
      From reading other posts on this forum and the NI forums, I've compiled the following suggestions:
      defer panel updates (helped a lot, but still too slow) set subVIs containing table Property Nodes to execute in 'user interface' thread (I've tried this but would love to know more about optimizing it. Should the subVI attempt to only contain Property Nodes with logic outside in a different thread?) maintain a "display" table which is a subset visible to the user (seems pretty complicated and may only give gains of factor of 2 or 3 since I want the Table to fill the user's monitor) obviously, take all steps to format by column, row, all (not possible for about half my columns whose coloring depends on each cell's value)

       
      Is the above list exhaustive? Can anyone suggest something I haven't listed? 
      I'd also appreciate more information about UI thread control. My naive understanding is that table coloring is so slow because to color cell-by-cell the process must switch up to the UI thread and back down. And setting a subVI property to the UI thread saves some of this thread-switching time?
       
      Barring any other insights, it seems like we've been burned by trying to use a table control in an unintended way and LabVIEW simply can't do it fast enough. Do XControls suffer from the same thread-switching problems for front-panel appearance updates via Property Nodes? Otherwise, I'll work on rewriting the UI in another language and simply feed the 2d string array to the rest of my LabVIEW code.
    • By boochbrain
      I ran into this error while developing the project I'm currently working on. I've isolated the cause of the error and I'm able to demonstrate it in a simple VI.
       
      Basically, if I make a new selection on an enum or ring, while using the "set cell value" method on a table, error 1604 is generated.
       
      I want to understand why this is happening and also be able to fix it.
       
       
      test error 1604.vi
×
×
  • Create New...

Important Information

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