[MAT logo][Prev][Up][Next]

Config

The config file is traditionally called matplc.conf (though you can give it any name you like). It determines what modules are running and any tuning parameters the modules require as well as configuring the MatPLC core, its global memory map and the like.

As such, the matplc.conf file is effectively the `main' file in any installation: all options and settings are either in this file, or in some file it specifies.

The Configuration Editor will be the easiest way to create and edit matplc.conf, once it is finished. For now, you will still have to do at least some editing with a text editor.

Example

There's an example config file in the Appendix. It may be useful to refer to it while reading this section.

Syntax

The config file is read line by line: for the most part, each line is interpreted separately, without regard to what's on the previous or following lines, with the exception of sections.

Lines that begin with # are comments, and are ignored. Comments may also be placed on the end of a line. To put a # into a value, enclose the whole value with quote marks, "

Quote marks may generally be used to enclose things that otherwise wouldn't be allowed in a value, like spaces or similar. Quotes may be included as \" and backslashes must then be \\

First line

We plan that in the future it'll be possible to make the config files executable scripts. This will be indicated on the first line with the usual #! magic. As far as the MatPLC itself is concerned, that's just a comment.

Sections

The config is divided into sections. There are two kinds of section names: one is simply prescribed, at present there's only one of those, named PLC. In addition, when a module is started, it is always given a name, and this name is used as the config section to retrieve all settings. In this way, two modules of the same kind (for instance two Modbus modules, to run on different serial ports) can be started at once without interfering with one another by giving them different names.

Sections are indicated in two ways:

Sections may be freely switched throughout the config files; the MatPLC sorts them out as it reads it from disk.

Single values

Single values are set in the config using the syntax:
name = value
In each section, each setting can only be given once, because it doesn't make sense to have two different settings for the same option. (Technically, it can be repeated, but only if they all have exactly the same value.)

Tables

Multiple values, known as "tables", are set using the syntax:
name value value...
name value value...
...
These may be interspersed with other settings and tables, even in separate pieces of a section or different files. When the config is read in, all the pieces of each table are joined together exactly as though it was given in one place.

Note that the first value in each row must start with an alphanumeric; if you need to start it with a punctuation symbol, enclose it in quotes. This is because the MatPLC needs to be able to distinguish tables from single values and so on.

File inclusion

Other files may be included in the config using the syntax
*include filename
This allows one to separate the config into various logical pieces, for instance by module, or to have various configurations of options with common pieces being in common files.

The included files may themselves *include others, and so on. Even circular *includes are supported and handled sensibly: each file will only be read once. Shell expansion is also done, so filename may include wildcards, environment variable substitution, and so on (however, backticks are not allowed).

Sections do not continue from one file to another: each file must take care of its own sections. In effect, this basically means that each file must start with a [section] header, possibly after some comments.

[Prev][Up][Next]

$Date: 2004/12/28 05:32:10 $