Jump to content

Writing configuration file


Recommended Posts

Hi. Bit over my head here.

I am trying to create a configuration for a fairly complex application that reads hardware. The configuration file will have a ton of diffrent options and parameters, each of which will have other options. Think of it more like trying to write a data tree. It also has to be editable easily.

Whats the best way to go about doing this? I was thinking XML, maybe. The easiest method I think would be to use Varient Attributes, but they arn't being written to the XML file (Only the varient data is, not the attributes), is there a way around this? Or a better way to store data?

Some details:

The data being stored is configuration data for hardware sensors, such as accelerometers. Each hardware peice will have a variant number of channels, and each channel could protentially support different sensors. Plus you have Gain and other options for each Channel, and a list of valid commands for each peice of hardware and the commands to start it running (Such as SET_CHANNEL, ect.) Also required are the sensor information. Each type of sensor will have a configuration setup.

All this has to be written into a configuration file that is easy editable so new hardware can be added as they are created.

Thanks in advance!

Link to comment

QUOTE(Puzzlemaker @ Aug 13 2007, 11:31 AM)

Hi. Bit over my head here.

I am trying to create a configuration for a fairly complex application that reads hardware. The configuration file will have a ton of diffrent options and parameters, each of which will have other options. Think of it more like trying to write a data tree. It also has to be editable easily.

Whats the best way to go about doing this? I was thinking XML, maybe. The easiest method I think would be to use Varient Attributes, but they arn't being written to the XML file (Only the varient data is, not the attributes), is there a way around this? Or a better way to store data?

Some details:

The data being stored is configuration data for hardware sensors, such as accelerometers. Each hardware peice will have a variant number of channels, and each channel could protentially support different sensors. Plus you have Gain and other options for each Channel, and a list of valid commands for each peice of hardware and the commands to start it running (Such as SET_CHANNEL, ect.) Also required are the sensor information. Each type of sensor will have a configuration setup.

All this has to be written into a configuration file that is easy editable so new hardware can be added as they are created.

Thanks in advance!

:question:

Clarification question:

Could you post a cluster or an array of clusters that shows the data you need to write or restore from file?

That will help us advise. :thumbup:

Ben

Link to comment

QUOTE(Ben @ Aug 13 2007, 11:38 AM)

:question:

Clarification question:

Could you post a cluster or an array of clusters that shows the data you need to write or restore from file?

That will help us advise. :thumbup:

Ben

Well, no, because I have no idea how to even store them, and I haven't created all of them yet. I will post what I have though.

Data.jpg

This is the command information for the hardware, one of the things that has to be in the configuration. The Port A is the hardware type.

There will also be a list of channels for each Port (Hardware piece), and each channel will have what controls to show on the front panel (A list of labels), plus what options each one of those controls can have.

The Sensor information will also be a list of each different kind of sensor, with a list of controls to show on the front panel, plus what each option can be.

Link to comment

QUOTE(Puzzlemaker @ Aug 13 2007, 11:48 AM)

Well, no, because I have no idea how to even store them, and I haven't created all of them yet. I will post what I have though.

Data.jpg

This is the command information for the hardware, one of the things that has to be in the configuration. The Port A is the hardware type.

There will also be a list of channels for each Port (Hardware piece), and each channel will have what controls to show on the front panel (A list of labels), plus what options each one of those controls can have.

The Sensor information will also be a list of each different kind of sensor, with a list of controls to show on the front panel, plus what each option can be.

That looks like Read from Spreadsheet or Write to Speadsheet file will handle that with not problems.

Ben

Link to comment

Is there any technical reason why you can't just create a database using an actual database program (MS Access as worst case)? XML file structure is the most flexible format if you can't do that but you will need to spend some design time figuring out how to best accomplish your goal. Even though XML is great in some respects, it can still be difficult to visualize the actual relationships of the data by looking at an XML Structure as compared to explicitly defining the relationships in a database.

Link to comment

You might want to take a look at Open G's varient configuraiton files.

www.openg.org

It takes Clusters or arrays and saves them as .ini files.

I would also sugest taking a look at the .tdm file fromat from NI. It uses an XML header with a binary file.

Hope this helps

Dan

Link to comment

QUOTE(Puzzlemaker @ Aug 14 2007, 01:24 PM)

Thanks a ton!

Yeah, I ended up with a super-complex cluster. I was trying to avoid that, thinking maybe there was some sort of way to store the data.

Again, appreciate the help! Looking into the Open G stuff now!

Please let us know how things work out.

There may still be other solutions, but first try the OpenG approach.

Ben

Link to comment

QUOTE(Puzzlemaker @ Aug 14 2007, 12:24 PM)

Yeah, I ended up with a super-complex cluster. I was trying to avoid that, thinking maybe there was some sort of way to store the data.

Can you explain this statement a bit further. How would the data storage avoid the need to develop a large complex data structure? As was mentioned earlier this is really two separate problems; desiging the data structure (cluster or otherwise) to contain your configuration information and, secondly, storing that data structure in a file.

The cluster is the most native way to store such a structure in LabVIEW, but other options are available. Then storing such a structure is the seocnd challenge. Quick and dirty ways to store any cluster from LabVIEW into a file is the Datalog file or the conversion to XML/XML file storage VIs included in LabVIEW.

The XML functions are in a sub-palette of the string palette, while the Datalog File VIs are found in a sub-palette of the Advanced File Functions.

Christian

Link to comment

QUOTE(LV_FPGA_SE @ Aug 14 2007, 03:20 PM)

... Quick and dirty ways to store any cluster from LabVIEW into a file is the Datalog file or the conversion to XML/XML file storage VIs included in LabVIEW.

...

Christian

Don't both of those methods suffer from the "NI redefined the data format" issue that complicates reading files writen in earlier versions of LV when upgrading?

Ben

Link to comment

Update: I got it working, reading in. I need to add more stuff now. This configuration file is getting x-treme.

I put in a formula for each sensor in the configuration file (AKA a strain gauge formula).

You put in names of objects on the front panel and it parses through and replaces those with constants, and then sticks them through the eval formula node VI. This lets you define the formula for each sensor type in the configuration without having to hardcode it.

Its sad I can't use if statements in the formula, but whatever.

Now I just have to figure out how to store how the front panel controls effect each other. Example:

When Dropdown A is option 1, show dropdown B. When Dropdown A is option 2, show numeric input C. When numberic input C is shown, numeric D equals numeric C... ect

I am considering writing a lab-view based script that has if statements so I can define that stuff in the configuration easily. Any suggestions?

Link to comment

A simple solution I've found for storing complicated data structures in xml is to have an array of clusters that each contain a name field (string) and a value field (string). Then, when writing data, flatten it to string and give it an ID in the name field. When you need that peice of data again, simply search the array for that name and unflatten the value. It's not the fastest thing in the world but if your configuration files change and you want to remain backwards compatible you will still be able to read the old values.

Link to comment

Warning! Shameless plug follows.

I will be posting a Nugget on a technique I discovered for accessing complex data structures entities starting only with a generic reference to a control on Sunday evening.

It should survive LV upgrades structure redefinitions and re-ordering of clusters.

I'll post here once it is posted.

End of Shameless plug.

Ben

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...

Important Information

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