Getting Started

This chapter shows how to install FcfSim and run an existing device simulator, before writing your own (covered in FCFsim SDK Description and the implementation chapter).

Installation

FcfSim is a waf project. Build and install it into your environment:

git clone https://gitlab.eso.org/ifw/ifw-fcfsim.git
cd ifw-fcfsim
waf configure
waf build
waf install

After installation the fcfsimServer and ifwFcfSimTmcExport commands are available on the PATH.

Running a single device

Every simulator is started by the same executable, fcfsimServer, pointed at a configuration file and an OPC UA port. To run one of the bundled example devices (a lamp):

fcfsimServer --cfg config/ifw/fcfsim/example/lamp.cfg.yaml --port 4840

This starts an OPC UA server on port 4840 exposing the lamp’s nodes and methods. The two mandatory options are:

  • --cfg / -c — the configuration file.

  • --port / -p — the OPC UA server port.

Run fcfsimServer -h for the full list of options (instance selection with --cfgname, logging control, external IP, debug shell).

The configuration file is plain YAML using the configng schema syntax. The lamp example is simply:

!cfg.include schema/ifw/fcfsim/devices/lamp/lamp.schema.yaml:

lamp: !cfg.type:FcfSimLampCfg
  device_name:  Lamp1
  prefix:       MAIN.Lamp1
  local_mode:   false
  sim_init_time: 2
  warm_up: 2
  cool_down: 2

Connecting a client

Once the server is running, connect any OPC UA client to opc.tcp://<host>:4840 to browse the namespace, read/write values and call methods. ESO’s uatools (UaExplorer for browsing, UaShell for a command-line client) work well for this, as does any generic OPC UA client.

A typical first interaction is to take the device through its state machine — for example calling its RPC_Init / RPC_Enable methods and watching the stat nodes change.

The debug shell

Adding --debug starts the server and drops you into an IPython shell with the running simulator engine bound to e. This is the quickest way to drive a device interactively while it runs:

fcfsimServer --cfg config/ifw/fcfsim/example/lamp.cfg.yaml --port 4840 --debug
In [1]: e.lamp1.init()        # call business-logic methods directly
In [2]: e.lamp1.stat.state    # inspect simulator state

Running several devices at once

The new manager (mgr) runs several device simulators in a single process, served by one fcfsimServer. A manager configuration lists the devices, each pointing at a device configuration file (optionally a named block via file.yaml::block), with per-instance overrides:

!cfg.include schema/ifw/fcfsim/mgr/simmgr.schema.yaml:
!cfg.include schema/ifw/fcfsim/devices/lamp/lamp.schema.yaml:

devsimmgr: !cfg.type:FcfSimMgrCfg
  update_frequency: 10            # OPC UA server update rate (Hz)
  devices:
    - name: lamp1
      cfgfile: 'config/ifw/fcfsim/example/lamp.cfg.yaml'
      overrides:
        - {name: prefix, value: MAIN.Lamp1}
    - name: motor1
      cfgfile: 'config/ifw/fcfsim/example/motor.cfg.yaml'
    - name: adc1
      cfgfile: 'config/ifw/fcfsim/example/adc.cfg.yaml::adc'

Run it the same way as a single device:

fcfsimServer --cfg config/ifw/fcfsim/example/mgr.cfg.yaml --port 4840

A complete example, exercising every standard device, ships at config/ifw/fcfsim/example/mgr.cfg.yaml.

Next steps

  • To implement your own device simulator, see the implementation chapter and FCFsim SDK Description.

  • To generate most of a new simulator from a Beckhoff TMC model, use ifwFcfSimTmcExport (run ifwFcfSimTmcExport help and ifwFcfSimTmcExport doc).