Jump to content


Photo
- - - - -

[CR] Data Repository with INI files (not a Source-Code-Control)


  • Please log in to reply
10 replies to this topic

#1 sam

sam

    Very Active

  • Members
  • PipPipPip
  • 56 posts
  • Version:LabVIEW 2011
  • Since:1997

Posted 30 October 2006 - 09:57 PM

Posted Image

File Name: Data Repository with INI files (not a Source-Code-Control)
File Submitter: sam
File Submitted: 30 Oct 2006
File Updated: 31 Oct 2006
File Category: Database and File IO

Data.vi V1.0.0
LabVIEW Versions 7.0,7.1
Copyright © 2006, Sam Behashtei
All rights reserved.

Author:
Sam Behashtei
Sam@Amashe.com

Distribution:
This code was downloaded from:
http://forums.lavag.org/downloads.html

Description:

The purpose of the VI is to demonstrate how to save all your application’s parameter in one central INI file. Using this method will reduce errors and eases debugging.

This Data VI has the following functionality

1: Can be used as a Central Data Repository for your Application.
2: It allows access to the Data via SET/GET method.
3: It uses semaphores to stop any race conditions and (concurrent SET access to data)
It will allow parallel "READ-ONLY" access to the Data.
4: A Function to Save all of the DATA to an INI file.
5: A Function to Load a previously saved Data from the INI file.



Support:
If you have any problems with this code or want to suggest features:
http://forums.lavag....?showtopic=4655



Version History:
1.0.1:
Added LabVIEW 7.0 code.
1.0.0:
Initial release of the code.

Library Dependency
OpenG: oglib_variantconfig-2.6-
OpenG: oglib_lvdata-2.5-1
http://www.openg.org

License:
Creative Commons Attribution 2.5 License

Click here to download this file

#2 Bobillier

Bobillier

    Very Active

  • Members
  • PipPipPip
  • 146 posts
  • Location:Rennes France
  • Version:LabVIEW 2009
  • Since:2009

Posted 31 October 2006 - 02:36 PM

Please is it possible to have your code in 7.0 ?
Regards
Eric

#3 sam

sam

    Very Active

  • Members
  • PipPipPip
  • 56 posts
  • Version:LabVIEW 2011
  • Since:1997

Posted 31 October 2006 - 03:59 PM

Hi,
I just added LabVIEW 7.0 code. Try to download again.

-Sam

#4 Neville D

Neville D

    The 500 club

  • Members
  • PipPipPipPipPip
  • 742 posts
  • Version:LabVIEW 2011
  • Since:1996

Posted 31 October 2006 - 04:59 PM

Hi,
I just added LabVIEW 7.0 code. Try to download again.

-Sam



Just as an aside, not to take away anything from Sam's effort, you can save/read back any LabVIEW data structure very easily to an xml file, making the ini file functions more or less redundant. I have written complicated structures of clusters/arrays/booleans very easily with just a single VI. The read is fairly easy as well.

I think the xml read-write VI's were introduced with LV 7.


Neville.

#5 sam

sam

    Very Active

  • Members
  • PipPipPip
  • 56 posts
  • Version:LabVIEW 2011
  • Since:1997

Posted 31 October 2006 - 06:32 PM

With this VI I am only pointing out exclusive write access to data. Inside the VI you can use ini or xml or databse to save your data to disk. I have used/using sqlite3 (using openg variants to save LabVIEW objects to sqlite3.). Also if you have a giant Cluster and pass it to openg's cluster to INI it will be saved in one action.

But I often browse the INI file with ini-aware text editor and grouping items makes it easier to browse.

#6 Michael Aivaliotis

Michael Aivaliotis

    MindFreak

  • JKI
  • 2,662 posts
  • Version:LabVIEW 2012
  • Since:1994

Posted 01 November 2006 - 08:04 AM

making the ini file functions more or less redundant

I disagree. I continue using ini's and still will well into the future. XML is great but it's not very human readable.
Thank You
Michael Aivaliotis

VI Shots

#7 Mike Ashe

Mike Ashe

    The 500 club

  • Premium Member
  • 814 posts

Posted 01 November 2006 - 02:01 PM

I disagree. I continue using ini's and still will well into the future. XML is great but it's not very human readable.

Especially NI's current version of XML. It is a bit verbose, but does seem to work. I'd like to see them compact it up a bit, and include attributes about the data on the same line instead of multple lines.

Again, not to take away from Sam's effort, which I think is great, but I like the INI version that Jim Kring did using the OpenG variant config file VIs. Sam's effort has the virtue of plugging in the file format of your choice. Perhaps this could be made an explicit plug in API. Keep up the good work Sam!

Lastly, if someone is going to use XML, (ie, NI's XML) it becomes marginally more readable if you indent it. There is a VI on NI Dev Zone to do this. Reformat LabVIEW XML for Simple Text Editors

#8 MartinD

MartinD

    Active

  • Members
  • Pip
  • 13 posts
  • Location:UK
  • Version:LabVIEW 2009
  • Since:1995

Posted 24 November 2006 - 03:04 PM

Hi all,

When I try to save an array all I get in the file is:

[Motion config]
Axis names.<size(s)>=0

Where "Motion Config" is cluster containing an array (labeled "Axis names") of strings with 8 elements. The size should be 8 and the element data should be stored in the file - right?. Does anyone what I'm doing wrong?

TIA - Martin
Certified LabVIEW Architect

#9 Randy

Randy

    Active

  • Members
  • Pip
  • 22 posts
  • Version:LabVIEW 8.6
  • Since:1997

Posted 27 November 2006 - 04:25 AM

Here is a VI that utilizes another method for reformating an XML file, this one doesn't care about incoming format since it is not doing the parsing through Labview itself but using the SAX Reader.
Download File:post-3040-1164601534.vi
Randy

Lastly, if someone is going to use XML, (ie, NI's XML) it becomes marginally more readable if you indent it. There is a VI on NI Dev Zone to do this. Reformat LabVIEW XML for Simple Text Editors



#10 MartinD

MartinD

    Active

  • Members
  • Pip
  • 13 posts
  • Location:UK
  • Version:LabVIEW 2009
  • Since:1995

Posted 27 November 2006 - 11:10 AM

Hi all,

When I try to save an array all I get in the file is:

[Motion config]
Axis names.<size(s)>=0

Where "Motion Config" is cluster containing an array (labeled "Axis names") of strings with 8 elements. The size should be 8 and the element data should be stored in the file - right?. Does anyone what I'm doing wrong?

TIA - Martin


Figured out myself - Needed to set the data before saving, of course! :headbang:
Certified LabVIEW Architect

#11 crelf

crelf

    I'm a LAVA, not a fighter.

  • V I Engineering, Inc.
  • 5,742 posts
  • Version:LabVIEW 2012
  • Since:1993

Posted 27 November 2006 - 12:51 PM

...Needed to set the data before saving, of course!

Bugger! :laugh: I couldn't replicate your problem - now I know why ;)

post-181-1170858537.png