Skip to content

Simulating a control system

Will Rogers edited this page Oct 11, 2019 · 6 revisions

For testing, it can be useful to simulate a control system.

This has various benefits:

  • It allows one to test without access to a running control system.
  • It allows one to test extreme states of the control system.
  • It allows one to test setting values that one would not want to in a control system.

A high level design doc.

The control system simulation consists of:

  • A component run within the browser that provides updates to process variables
  • A DSL that defines those process variables that should be simulates
  • A DSL that defines how process variables should be updated.
  • A mechanism whereby these DSLs can be specified.

Possible values

The types that are used in the cs-web-proto repo are VTypes, which are an implementation of EPICS normative types (see the wiki page). This implementation is copied from Java: part of the epicsCoreJava repo here.

Interface

When a component requests a PV with a prefix sim:// and a suffix which is understood, periodic updates should started that are dispatched to the store via the plugin interface.

Examples:

  • sim://sine: a double value that oscillates about zero
  • sim://disconnector: a random double value that occasionally disconnects
  • sim://readonly: a random double value that has readonly set to true (actually all the sim PVs should be readonly really so perhaps this is not necessary)
  • sim://sinewave: a double array that shows a sinewave moving over time
  • sim://alarm: a double value that has an alarm state that changes at random

Local PVs

There is similarly a use for 'local' PVs with a loc:// prefix. These are different but could also be supported. They cache a value supplied by the UI and update the store when it changes.

These are supported by CS-Studio and Phoebus so we have an existing definition to work with.

Related reading

Epics 7 provides a process variable introspection interface it might make sense to copy this.

Beyond scope

This simulation might be useful for functional testing.

One could imagine quite complicated interactions with a control system (mocking the interaction with the control system). One could imagine mocking this value out.