This guide explains how to test the start/stop message implementation in splash_timepix, including integration with the ArroyoXPS listener.
-
Install splash_timepix (in its repo):
cd /path/to/splash_timepix pip install -e .[dev] -
For ArroyoXPS integration: create and use the
arroyoxpsconda environment and install ArroyoXPS there (see ArroyoXPS docs). -
Simulator is included for testing without hardware.
Use three terminals. Start in this order: server first, then listener, then simulator.
# Go to splash_timepix project
cd /path/to/splash_timepix
# Activate your splash_timepix environment (or base if installed there)
# conda activate splash_timepix # if you use one
python -m splash_timepix.app --tdc-frequency 10 --flush-interval 1.0Leave this running. You should see the server listening (e.g. on port 9090 for TCP, 5657 for ZMQ).
# Activate the arroyoxps conda environment (required)
conda activate arroyoxps
# Go to ArroyoXPS project
cd /path/to/ArroyoXPS
# Run the TimePix ZMQ listener (DummyOperator prints start/event/stop)
python -m tr_ap_xps.timepixLeave this running. It will connect to tcp://localhost:5657 (splash_timepix’s ZMQ port).
# Go to splash_timepix project
cd /path/to/splash_timepix
# Same environment as Terminal 1
python -m splash_timepix.simulator_cliThen in the simulator CLI:
cps 1000
tdc 10
start 10
This sends data for 10 seconds. Type stop or wait for the run to finish.
- splash_timepix server (Terminal 1): Logs when start/stop are queued and when flushes are published.
- ArroyoXPS listener (Terminal 2): Connects to
tcp://localhost:5657, receives and logs:- Start: e.g.
Dummy operator received START: scan_name=<uuid4>(scan_name is a full UUID4, e.g.a1b2c3d4-e5f6-4a7b-8c9d-0e1f23456789) - Events: e.g.
Dummy operator received EVENT with image shape: (256, 256, 350)(shape may vary) - Stop: e.g.
Dummy operator received STOP
- Start: e.g.
- Simulator (Terminal 3): Sends packets to the server;
start 10runs for 10 seconds.
If you see start, multiple events, and stop in the ArroyoXPS terminal, the pipeline is working.
This usually means the listener is running in the wrong environment or from the wrong directory.
-
Use the ArroyoXPS conda environment:
conda activate arroyoxpsThearroyopypackage (and correctZMQListenersignature) must be available in this env. -
Run from the ArroyoXPS project directory:
cd /path/to/ArroyoXPSThen runpython -m tr_ap_xps.timepixso thattr_ap_xpsand its config (e.g. ZMQ port) resolve correctly. -
Check ArroyoXPS code: In
tr_ap_xps.timepix,XPSTimepixZMQListenermust callsuper().__init__(operator, zmq_socket)(operator first, socket second) to matcharroyopy.zmq.ZMQListener. If you still see the error after fixing env/cd, verify that__init__passes arguments in that order.
- Confirm the server is running:
ps aux | grep splash_timepix - ZMQ default port is 5657; ArroyoXPS must use the same (see ArroyoXPS
settings.yaml/ config). - Start order: server → listener → simulator. If the subscriber connects after the server has already published the start message, you may miss start (ZMQ “slow joiner”); reconnect and trigger a new run.
- Ensure data is actually reaching the server (e.g. simulator connected and
startissued). - Run server with
--verboseto see when start is queued.
- Stop is sent on server shutdown (Ctrl+C) or when the client (simulator) disconnects.
- Check server logs for errors during shutdown.
- ZMQ address must match server port (default
tcp://localhost:5657). - Subscriber should subscribe to all:
socket.setsockopt(zmq.SUBSCRIBE, b""). - After starting the listener, wait a second before starting the simulator to reduce slow-joiner effects.
cd /path/to/splash_timepix
python -m splash_timepix.app --tdc-frequency 10 --flush-interval 2.0 --verbosecd /path/to/splash_timepix
python -m splash_timepix.simulator_cli
# In CLI: cps 1000, tdc 10, start 30cd /path/to/splash_timepix
python -m splash_timepix.example_zmq_subExpected: START with config, multiple EVENTs (flushes), STOP when run ends.
cd /path/to/splash_timepix
python -m splash_timepix.example_listenerExpected: Operator processes START, EVENTs, and STOP.
cd /path/to/splash_timepix
python tests/test_start_stop_messages.pyThis starts server and simulator in subprocesses, subscribes to ZMQ, and checks that start/event/stop messages are received.
cd /path/to/splash_timepix
# Schema validation + start/event/stop integration coverage
pytest tests/test_start_stop_messages.py -vThe schema-only assertions live inside class TestSchemas in that file; the
remaining tests in the module spin up the streaming server via the
streaming_rig fixture and assert on real ZMQ traffic.
- Start server:
cd /path/to/splash_timepixthenpython -m splash_timepix.app --tdc-frequency 1000 - Connect live-cli in another terminal.
- Start acquisition from live-cli (or your site workflow).
- Monitor:
python -m splash_timepix.example_zmq_sub
-
msg_type: "start" - Has
scan_name - Has config (tdc_frequency, detector_size, etc.)
- Sent when first data arrives
-
msg_type: "event"(or compatible) - Multi-part: metadata + array bytes
- Flush metadata (flush_number, shape, etc.)
-
msg_type: "stop" - Same
scan_nameas start - Stats: total_flushes, total_cycles, duration
- Sent on shutdown or client disconnect
- Subscribes to ZMQ (port 5657)
- Converts to schema objects
- Handles start, event, stop in order
Verbose server logging:
cd /path/to/splash_timepix
python -m splash_timepix.app --verboseShows when start/stop are queued and when ZMQ messages are published.