|
| 1 | +# What is FastCS? |
| 2 | + |
| 3 | +FastCS is a Python framework for building device drivers for scientific instruments. |
| 4 | +It separates the logic of communicating with a device from the control system used to |
| 5 | +expose it, so the same driver works with EPICS (CA or PVA), Tango, REST, and GraphQL |
| 6 | +without modification. |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +<div style="text-align: center"> |
| 11 | + |
| 12 | +```{raw} html |
| 13 | +:file: ../images/overview.excalidraw.svg |
| 14 | +``` |
| 15 | + |
| 16 | +</div> |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## Architecture |
| 21 | + |
| 22 | +A FastCS application has three layers: |
| 23 | + |
| 24 | +**Controller** - a Python class that models the device. It holds attributes and |
| 25 | +commands, implements connection logic, and creates periodic polling tasks. The |
| 26 | +controller can create `AttributeIO`s to handle `update` and `send` operations between |
| 27 | +attributes and the device. |
| 28 | + |
| 29 | +**Attributes and commands** - typed values (`AttrR`, `AttrW`, `AttrRW`) and callable |
| 30 | +actions (`@command`) declared on the controller. Attributes represent the device's |
| 31 | +readable and writable parameters and carry metadata such as units, limits, and alarm |
| 32 | +thresholds. Commands are actions that can be triggered to run. |
| 33 | + |
| 34 | +**Transport** - the protocol layer that exposes the controller's attributes and commands |
| 35 | +to a control system. FastCS provides transports for EPICS CA, EPICS PVA, Tango, REST, |
| 36 | +and GraphQL. |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +<div style="text-align: center"> |
| 41 | + |
| 42 | +```{raw} html |
| 43 | +:file: ../images/data-flow.excalidraw.svg |
| 44 | +``` |
| 45 | + |
| 46 | +</div> |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +Sub-controllers let you model hierarchical devices — a sub-controller's attributes are |
| 51 | +exposed under a prefixed path, and a set of identical sub-controllers can be grouped |
| 52 | +using `ControllerVector`. See [Controllers](controllers.md) for details. |
| 53 | + |
| 54 | +## Writing a driver |
| 55 | + |
| 56 | +To create a driver, subclass `Controller`, declare attributes and commands as typed |
| 57 | +class members, and implement lifecycle hooks (`connect`, `reconnect`, `disconnect`) and |
| 58 | +periodic scan tasks. The [tutorials](../tutorials.md) walk through a complete example. |
| 59 | + |
| 60 | +## Deploying as an application |
| 61 | + |
| 62 | +Passing the controller class to `launch()` generates a standard CLI with `run` and |
| 63 | +`schema` commands. The `run` command takes a YAML configuration file that specifies |
| 64 | +both the controller's settings and which transports to start. Swapping or adding |
| 65 | +transports requires only a config change, not a code change. See |
| 66 | +[Launching the framework](../how-to/launch-framework.md) for details. |
| 67 | + |
| 68 | +## Benefits |
| 69 | + |
| 70 | +**Simple API** — a driver is a plain Python class with typed class-variable attributes. |
| 71 | +There is no boilerplate or protocol-specific code in the driver itself. |
| 72 | + |
| 73 | +**Control-system-agnostic testing** — controllers have no dependency on EPICS, Tango, |
| 74 | +or any other control system and can be unit-tested as ordinary Python objects. Testing |
| 75 | +device logic does not require a running IOC or device server. |
| 76 | + |
| 77 | +**Multiple transports from a single driver** — the same controller can serve EPICS CA, |
| 78 | +EPICS PVA, Tango, REST, and GraphQL simultaneously or in any combination. |
| 79 | + |
| 80 | +**Automatic reconnection** — if a scan task raises an exception, FastCS pauses all |
| 81 | +tasks and calls `reconnect()` automatically, resuming once the connection is restored. |
| 82 | + |
| 83 | +**Auto-generated OPI screens** — EPICS transports generate CSS-Phoebus screen files |
| 84 | +from the controller's attribute metadata, with no additional effort from the driver |
| 85 | +author. |
| 86 | + |
| 87 | +**Interactive shell** — FastCS starts an IPython shell alongside the running driver, |
| 88 | +giving direct access to the live controller instance for inspection and ad-hoc commands |
| 89 | +without restarting. |
| 90 | + |
| 91 | +**Structured logging and per-attribute tracing** — FastCS uses |
| 92 | +[loguru](https://loguru.readthedocs.io/) for structured logging. The `Tracer` mixin |
| 93 | +adds TRACE-level logging to individual attributes, allowing fine-grained visibility |
| 94 | +into specific values without increasing the verbosity of the whole driver. |
| 95 | + |
| 96 | +**Graylog integration** — the generated CLI accepts a `--graylog-endpoint` option that |
| 97 | +forwards all log output to a Graylog instance, with support for static and |
| 98 | +environment-variable-sourced fields for log enrichment. |
0 commit comments