icepapd
ESRF ICEPAP daemon for Pylatus. Provides a TCP server that proxies ICEPAP crate and PI piezo controller commands and state via JSON.
The daemon connects to one or more ICEPAP crates and/or PI intermediate controllers, polls motor positions and status, and serves clients over TCP port 5000. Clients receive incremental JSON updates and send JSON requests to move motors, change parameters, etc.
Overview
icepapd implements a daemon that bridges the ESRF ICEPAP motor protocol and the PI piezo protocol to a simple JSON/TCP interface used by SPEC and other beamline software. The daemon maintains persistent connections to hardware hosts, polls positions/status with configurable delay, applies backlash correction, user coefficients, limits and SPEC configuration, and broadcasts state changes to connected clients.
The client protocol is line-delimited JSON. On connection clients receive a total crate count message and subsequent
CrateState updates. Requests are JSON objects with fields such as host, motor, move_motor, user_speed, etc.
Responses are JSON objects encoded by the server.
Components
main.rs- entry point, parses arguments viaParams, initializes logger, binds TCP listener on IPv6/IPv4 and startsTcpServer.params.rs- command line argument definition with clap, daemon options, verbosity, backlash type, step speed, always poll, SPEC config files.server.rs-TcpServerandIcepapdServeractors, client session management, request routing to devices, client notification.session.rs-ClientSessionactor handling framed JSON read/write per client connection.device.rs- common device abstraction,DeviceConfigfor persistent per-host config, request queueing and connector traits.krate.rs- ICEPAP crate actor, rack discovery, motor state machine, scanning, backlash, ECAM, SPEC config import.icepap_codec.rs- encoder/decoder for ICEPAP ASCII protocol and client JSON codec.pi.rs- PI controller actor, axes discovery, position/voltage/servo handling, scanning.pi_codec.rs- encoder/decoder for PI controller ASCII protocol.pi_errors.rs- PI error code mapping.utils.rs- message framing helpers, macros for command encoding.
Build
Requires Rust 2021 edition and Cargo. Dependencies are declared in Cargo.toml:
- actix, actix_derive, async-stream, tokio, tokio-util
- clap, daemonize, bytes, serde_json, serde
- num-traits, num-derive, confy, dirs
- besy - internal logging library
Build:
cargo build --release
The binary is produced as target/release/icepapd. Build metadata is generated by build.rs via vergen-gitcl.
Usage
Run with at least one ICEPAP host or PI host:
icepapd host.esrf.fr
Default TCP port for clients is 5000. Multiple hosts can be specified:
icepapd -p 5000 icepap 192.168.1.10 192.168.1.11 --pi 192.168.1.20
Common options:
-p PORT- TCP port to listen for clients, default 5000-l delay- poll delay in ms, default 0-v- verbosity level, repeat up to 3 times-d- run as daemon-m- add dates in messages--pi HOSTor-z HOST- PI piezo controller host, default port 7900-b simple|smart- backlash correction type, default simple--spec-config FILE- SPEC config file to import motor coefficients-s MOTOR- motor name to set step speed-a MOTOR- motor name to always poll even in scan mode--dynamic- query board name and activity on every request--fast-commands- use fast POS/FSTATUS commands
Clients connect via TCP to icepapd:5000 and exchange line-delimited JSON. Example request:
{
"client": "spec",
"version": "1",
"host": "192.168.1.10:5000",
"motor": "m1",
"move_motor": 10.0
}
Example server update:
{
"controller_type": "icepap",
"host": "192.168.1.10:5000",
"racks": 2,
"motors": [
...
]
}
The initial message after connection is a daemon info object:
{
"daemon": "icepapd",
"version": "1.4.0",
"crates": 2
}
License
GPL-3.0+