LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Maps and Config Files

I started using maps (finally).  Needing to initialize them from .ini files, I made this.

"If you weren't supposed to push it, it wouldn't be a button."
Message 1 of 20
(2,115 Views)

Malleable VI would have made your life easier I believe, not sure if there is a limitation of VIM with Maps.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 20
(2,095 Views)

@santo_13 wrote:

Malleable VI would have made your life easier I believe, not sure if there is a limitation of VIM with Maps.


This does seem to generally work for the writes at least. INI tokens are fairly limited in terms of acceptable data types so you might have to be careful. It doesn't accept all data types (variants and clusters break) but it will take a U64 map and write a double to INI which could cause runtime issues. Of course you could fix this with type checking but I'm not sure how much effort that would save over the existing poly VIs.

Matt J | National Instruments | CLA
0 Kudos
Message 3 of 20
(2,082 Views)

I haven't looked at you code, but have you considered moving away from INI format for config files?  INI is great for simple things, but poor for complex config info.

0 Kudos
Message 4 of 20
(2,059 Views)

@santo_13 wrote:

Malleable VI would have made your life easier I believe, not sure if there is a limitation of VIM with Maps.


I considered that, but most of the time I’ll be using the “read” functions, and most of the time, I won’t need to wire the map nor default inputs.  So I made it polymorphic in order to have a selector.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 20
(2,051 Views)

@drjdpowell wrote:

I haven't looked at you code, but have you considered moving away from INI format for config files?  INI is great for simple things, but poor for complex config info.


I actually have a nice OOP based config file system that handles any data type.  But sometimes it’s desirable to have human-editable files.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 6 of 20
(2,047 Views)

I mean something like JSON.  Still human editable, but capable of storing complex data.

0 Kudos
Message 7 of 20
(2,032 Views)

@drjdpowell wrote:

I mean something like JSON.  Still human editable, but capable of storing complex data.


I consider that a bad compromise.  Readability is unpleasant.  Try explaining to a non-tech how to change a setting in a JSON file.  And from a programming standpoint, the code wouldn’t be as clean as using a binary file.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 8 of 20
(1,987 Views)

@paul_cardinale wrote:
I consider that a bad compromise.  Readability is unpleasant.  Try explaining to a non-tech how to change a setting in a JSON file.  

Seems very readable to me.  An example:

{
  "Module_DB file":"",
  "SQLite busy timeout (ms)":10000,
  "Analysis Configuration":[],
  "Column Widths":{
    "AnalysisName":82,
    "Camera":65,
    "Colour":46,
    "ImageIndex":21,
    "InValid":42,
    "Pattern":52,
    "TestTime":131,
    "unitID":111
  },
  "Overlay Options":{
    "ID":true,
    "Alignment":{
      "Alignment Markers":"Input and Output",
      "Edge Detection":false,
      "Circular IG":false
    }
  }
}

 


@paul_cardinale wrote:
And from a programming standpoint, the code wouldn’t be as clean as using a binary file.

There is no way an OOP-based config system is going to be as clean to code as using a good JSON library.  

0 Kudos
Message 9 of 20
(1,977 Views)

@drjdpowell wrote:

@paul_cardinale wrote:
I consider that a bad compromise.  Readability is unpleasant.  Try explaining to a non-tech how to change a setting in a JSON file.  

Seems very readable to me.  An example:

{
  "Module_DB file":"",
  "SQLite busy timeout (ms)":10000,
  "Analysis Configuration":[],
  "Column Widths":{
    "AnalysisName":82,
    "Camera":65,
    "Colour":46,
    "ImageIndex":21,
    "InValid":42,
    "Pattern":52,
    "TestTime":131,
    "unitID":111
  },
  "Overlay Options":{
    "ID":true,
    "Alignment":{
      "Alignment Markers":"Input and Output",
      "Edge Detection":false,
      "Circular IG":false
    }
  }
}

 


@paul_cardinale wrote:
And from a programming standpoint, the code wouldn’t be as clean as using a binary file.

There is no way an OOP-based config system is going to be as clean to code as using a good JSON library.  


Better readability than XML for sure, more intimidating than a classic config (.ini) file for a non-tech person, though.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 20
(1,936 Views)