This project has moved and is read-only. For the latest updates, please go here.

Config Section in Calculated Measurements

Apr 26, 2011 at 4:34 PM

Do we have an example of Calculated Measurements that uses the "Config Section". Documentation says: "If the custom adapter has settings that need to be saved in the openPDC configuration file, this property represents the section under which these settings should be placed in the configuration file." Is there an example that we can look at? Thanks!

Apr 29, 2011 at 8:51 PM
Edited Apr 29, 2011 at 8:52 PM

The config section allows you to generically specifiy a configuration section for use by your adapter when you need extra semi-static configuration information (e.g., database connection strings).

Here is what an example might look like:

using TVA;
using TVA.Configuration;

// Make sure setting exists to allow user to by-pass optimizations at startup
ConfigurationFile configFile = ConfigurationFile.Current;
CategorizedSettingsElementCollection settings = configFile.Settings[ConfigurationSection];

// This call will only add setting if it does not already exist...
settings.Add("OptimizeMyCalculation", true, "Determines if my calculation will perform an optimization step at startup"); // See if user has requested optimize if (settings["OptimizeMyCalculation"].ValueAsBoolean()) { // TODO: Perform Optimization... }
Apr 29, 2011 at 8:56 PM

Thanks for the explanation and example.