Configuration

Configuration file syntax is YAML. The objects drivers and interfaces are associative arrays where the key defines the type of driver/interface and the value is a list of instance name. For example in the configuration listed below we have one modbus instance with the name mb0.

Configuration for each single instance goes into driver.<driver_type>.<driver_name>.<setting_name> or interface.<interface_type>.<interface_name>.<setting_name>.

advanced YAML helpers

Sometimes it'd make sense to generate parts of the config via Python. For example if configuration items could be produced by iterating a list or loop. For this case these special YAML tags are helpfull:

  • !py.Function <package>.<function>@<package path>
  • !py.FileFunction <function>@<File.py>
  • !File <File.yaml>

Examples

simple full config

drivers:
  modbus:     [mb0]
  daikin_itc: [itc_0,itc_1]
  fias:       [fias]

interfaces:
#  json:      [zmq_sync,zmq_pub,tcp]
  json:      [tcp]

interface:
  json:
    tcp:
      #uri_prefix=/mb_slave
      debug:        False
      transport:    TCP
      listen:       127.0.0.1
      port:         8000

driver:
  modbus:
    mb0:
      mode:           master
      debug:          False
      port:           /dev/ttyMB
      baudrate:       19200
      parity:         even
      bits:           8
      type:           pyRTU
      stopbits:       1
      asynchronous:   True
      autopoll:       True
      sleep_interval: 0.1
      int_values:     True

  fias:
    fias:
      host:          protel
      port:          5009
      type:          tcp
      role:          client

  daikin_itc:
    itc_0:
      address:      daikin_itc_0
      merge_rw:     False
    itc_1:
      address:      daikin_itc_1
      merge_rw:     False
    itc_2:
      address:      daikin_itc_2
      merge_rw:     False
 

logging:
  version:         1
  root:
    level:         DEBUG
    handlers:      [console]

  loggers:
    default:
      level:       DEBUG
      handlers:    [console]
      propagate:   no
#service:
#  level=DEBUG
#  handlers=logfile

  formatters:
    simple:
      format:      "%(asctime)s %(levelname) 8s| %(message)s"
    verbose:
      format:      "%(asctime)s %(levelname) 8s| %(message)s"

  handlers:
    console:
      class:      logging.StreamHandler
      level:      DEBUG
      formatter:  simple
      stream:     ext://sys.stdout

generated config part via !py.Function

controller:
  logging:
    logging:
      database:
        type:      sqlite
        file:      /etc/sdo/logging.db
      logs:
        !py.Function gh_pfeifer.getConf_Logging_Logs@/etc/sdo
def getConf_Logging_Logs():
	conf={}
 
	conf['/fbm/_abstracts/CustomDevice/Global/T_Outdoor']=[5000,300]
	for cType in CELL_TYPES:
		for cell_id in CELLS[cType]:
			conf['/fbm/_abstracts/CustomDevice/Cell_%i/T_Room'%cell_id]=[5000,300]
 
	return conf

Will generate something like:

controller:
  logging:
    logging:
      database:
        type:      sqlite
        file:      /etc/sdo/logging.db
      logs:
        /fbm/_abstracts/CustomDevice/Global/T_Outdoor:   [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_1/T_Room:   [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_2/T_Room:   [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_3/T_Room:   [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_4/T_Room:   [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_5/T_Room:   [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_6/T_Room:   [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_7/T_Room:   [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_8/T_Room:   [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_9/T_Room:   [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_10/T_Room:  [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_11/T_Room:  [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_12/T_Room:  [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_13/T_Room:  [5000,300]
        /fbm/_abstracts/CustomDevice/Cell_14/T_Room:  [5000,300]
doc/sdo/config.txt · Zuletzt geändert: 2015.06.15 - 08:34 von 127.0.0.1
 
Copyright 2021, e-design / Alexander Krause