Simple Configuration File - Subroutine


#1

Hello Everyone,

I’ve created a config file where all the numeric settings, for my PAC strategy are stored. For example, temperature settings, sprinkler system settings, offsets, temperature limits, etc. Strategy periodically reads the config file for new settings and applies them. So right now in order to adjust any settings in my program, I don’t have to stop the strategy and hard code new values, all I have to do is to edit the config file (manually or thru my web interface).

I’ve created two SUBs:

  • read_config_file - it reads specified file from root directory of the controller and puts its content into the string table (config table).
  • read_config_table - it reads numeric value of parameter from the config table

I’ve attached 4 files:

  • subs read_config_file and read_config_table,
  • test.conf - config file which needs to be uploaded to root directory of your controller,
  • demo strategy.

Demo strategy reads the config file (test.conf) and waits number of seconds defined in refresh_rate and goes back to beginning to read the file again.

Enjoy.