(c) 2016-2018 European Spallation Source, Lund Author: Gregor Ulm, Krisztian Loki, Miklos Boros
PLC Factory is intended to simplify programming PLCs and creating the communication interface between EPICS and PLCs. It is also capable of processing text files and substituting specially formatted expressions that are defined as properties in CCDB. It takes an arbitrary device and a list of template ids as input and processes the corresponding sub-tree of devices according to their entries in CCDB.
PLC Factory requires Python 2.7.
Automaticly generate the PLC block and the corresponding IOC from CCDB using .def files. The .def files are linked to the CCDB device types.
Generate TIAv14 blocks (diagnostics code included) with EEE module:
python plcfactory.py -d CrS-CMS:Cryo-PLC-01 --plc-interface=14 --eee
Generate TIAv14 base blocks (diagnostics code included) with EEE module:
python plcfactory.py -d CrS-CMS:Cryo-PLC-01 --plc-direct=14 --eee
Using manually created PLC Factory templates:
Invocation follows the pattern
python plcfactory.py --device <device> --template <ids>, where
ids is a list of template names of at least one element.
python plcfactory.py --device LNS-LEBT-010:Vac-PLC-11111 --template EPICS-DB TIA-MAP
python plcfactory.py -d LNS-LEBT-010:Vac-PLC-11111 -t EPICS-DB TIA-MAP
The resulting output file(s) will be written to a dedicated directory (derived from the device name) in the
For further information, see the files in doc.
General purpose options
- The root device of the controls hierarchy in CCDB
- --template list of templates
- [REQUIRED if not using any plc options]
- The list of templates to process
--template EPICS-DB TIA-MAP MY-SPECIAL-TEMPLATE
- Use the specified CCDB-dump of device instead of connecting to the CCDB database
- Use the test version of the CCDB database
- shorthand for --ccdb-test
- Use the production version of the CCDB database. This is the default.
- Create a zip file containing the generated files. The default file name is derived from device
- Used to select the correct template if more than one template was found
- template filenames like
- Interface Definition filenames like
- Interface Definition URLs with name
- template filenames like
PLC Factory is capable of integrating (and generating code for) the following PLC types:
Siemens SIMATIC S7-1200 / S7-1500 (selected with either the
- TIA Portal v13
- TIA Portal v14
Beckhoff (selected with the
- TwinCAT 3
Options related to EPICS-PLC integration
- Generate the EPICS db, the communication and diagnostics PLC code for the specified TIA version. The default version is TIA Portal v14
- Generate the EPICS db, the communication, data (de)serialization, and diagnostics PLC code for the specified TIA version. The default version is TIA Portal v14
- Generate the EPICS db, the communication and data (de)serialization PLC code for TwinCAT 3 (Diagnostics is not yet supported)
- Generate diagnostics PLC code
- Do not generate diagnostics PLC code. This is the default
- Only diagnostics PLC code is generated
- Generate a proper EEE module. The default module name is derived from device and of course prefixed with m-epics. Implicitly adds EPICS-DB, AUTOSAVE-ST-CMD, and AUTOSAVE to the list of templates (which means you don't have to add any templates explicitly)
- Change the root prefix in the generated EPICS db from device to the specified string.
--plc-beckhoff is required for EPICS-PLC integration. These options implicitly adds EPICS-DB, IFA, and the proper TIA-MAP to the list of templates (which means you don't have to add any templates explicitly).
The information on what is exchanged between EPICS and a PLC is defined in so-called Interface Definition files. For further information, please see template_factory
Assigning Interface Definition files to devices
Assigning Interface Definitions happens on the device type-level in CCDB. Every device that belongs to the same device type has the same Interface Definition. There are 2 distinct ways of assigning:
- Upload the Interface Definition file as an Artifact of the device type. The only restriction is that the file must have a .def extension.
Upload the Interface Definition file to a Git repository (only Bitbucket has been tested so far) and add the URL to the repository (without the .git extension) as an External Link to the device type and use EPI as the link name. By default PLCFactory constructs the filename to download as follows:
- takes the name of the device type
- in all uppercase
- changes reserved characters (<, >, :, ", /, \, |, ?, *) to _
- appends .def
It is possible to explicitly specify the filename in square brackets after EPI; EPI[file-to-download]. The file must still have a .def extension (although it is automatically appended if not already specified). This technique can be used to share the same Interface Definition across device types. It is possible to specify a version of the .def file to use other than master with the EPI VERSION property (either on slot or device type level)