NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically load Database Schema

I have created a custom Database Schema which I exported to a file from the 'Database Option' window. I was wondoring if there is a way to programatically Import the new schema. I would like to do this so that when I install the test software on a clean system there will not be a need to manually import the schema though the sequence editor.

 

Thanx in advance

 

john

0 Kudos
Message 1 of 10
(5,152 Views)

John -

There is not a simple API to import the schema into the system. A more low-tech way is to add/replace the default TestStandDatabaseOptions.ini file in the Cfg directory with the copy that you have that has your customizations. This way the new system will have exactly the settings that your require.

Scott Richardson
https://testeract.com
0 Kudos
Message 2 of 10
(5,140 Views)

This was posted way back in 2008.  Does this statement still hold true or is there now a way in TS 2012?

 

Update:  I think I will try the ReadEx command similar to that which I used in the report options.

0 Kudos
Message 3 of 10
(4,761 Views)

According to KB 37O9H144, if you are creating a TestStand deployment, then all you have to do is make sure to include the TestStandDatabaseOptions.ini file in the deployment. If you are moving the schema without a deployment, you can use the export feature in theSchemas tab of the Database Options dialog box to generate an INI file. Then use the import feature to automatically load the schema in TestStand.

Taylor B.
National Instruments
0 Kudos
Message 4 of 10
(4,738 Views)

Got it.  But in this case, we are not currently using a deployment, each machine will have the Dev Environment.  And since my goal is to not stomp on anyone's personal settings or have to create instructions for each person (which could be anywhere in the world), I have created a way to modify the .ini file (if it exists) and insert my options.  It's not elegant, but I believe it will work fairly well.  I can get into more detail if you are interested.

0 Kudos
Message 5 of 10
(4,735 Views)

It seems like using the import and export features of the Schema tab in the Database Options dialog would work. The export feature creates an INI file for your schema that can be loaded with the import function.

Taylor B.
National Instruments
0 Kudos
Message 6 of 10
(4,729 Views)

Yes, that can be done, but I'm forcing it through my client file/process model so that it has to use my version and not a possible modified version.  The user will never know it happened, but at the same time, it will not affect any personal settings they may have for their own work.  I'm basically doing the same thing an installer would do in a deployment.

0 Kudos
Message 7 of 10
(4,726 Views)

Hi all,

 

Has anything changed on this matter?  I've got a custom database results processor plugin that needs to "just work." Meaning, I want it to load its schema automatically.

 

I'd rather not swap out TestStandDatabaseSchemas.ini if I can help it...  I suppose I could modify that file, but that's messy.

 

I notice that in this help article refers to the following method:

ReadDatabaseSchema (engine, schemaName, databaseSchema, fileDirectory)

However, it always looks for TestStandDatabaseSchemas.ini.  Is there a similar function nowadays that isn't hard coded to look for that specific file?

 

It seems like programmatically modifying the .ini file may be my best option here...

0 Kudos
Message 8 of 10
(4,082 Views)
0 Kudos
Message 9 of 10
(2,114 Views)

At long last, I have figured out at least one way to do this successfully and consistently. If this helps you out, kudos are always appreciated.

This probably isn't the only way to do it, but it's working for me.

I started writing a complete tutorial, but it ended up being very, very long.

 

Here's a summary:

  • Export the schema you want to use as a file, using the Database Options dialog for the database plugin
  • Use ReadEx to read the schema file above and place its data structures in memory
  • Use the imported schema above as a single element of an array of type NI_DatabaseOptionsSchema
  • Rewrite TestStandDatabaseSchemas from scratch using the PropertyObject.Write() method
    • First write a property of type DatabaseOptions
    • Next, write the array of NI_DatabaseOptionsSchema
  • Create a working copy of the database plugin that will be used during execution (literally copy the sequence file)
  • Set ModelPluginComponentDescription.Default.PluginSpecific.Options.DatabaseSchema by cloning the imported schema

Dynamically load the model plugins (easier said than done).

  • Use the Engine method, ReadPropertyObjectFile() to load ResultProcessing.cfg into memory
  • Modify Data.ModelPluginConfigurationSet.Configurations["<Default for Inline Processing>"].Plugins to your needs
    • Side Note: be sure to use the working copy of the database plugin that has your schema configured!
  • Commit changes to ResultProcessing.cfg using the PropertyObjectFile method, WriteFile(WriteFileFormat_Current)
  • To keep things consistent, set PropertyObjectFile.FileWritingFormat to FileWritingFormat_Xml. The default binary format will be read by TestStand without issue, but the traditional format of ResultProcessing.cfg is XML
  • Call the ReadModelPluginConfiguration function from modelsupport2.dll, which will cause ResultProcessing.cfg to be read into TestStand and committed as the current configuration.

Of course there are many, many details that would go on for pages, but this is the basic methodology I'm using successfully.

 

P.S. NI, it sure would be nice if this were a bit easier and more intuitive.

 

0 Kudos
Message 10 of 10
(1,996 Views)