A Python command sequencer to allow easy scripting of ODIN control systems.
- Free software: Apache Software License 2.0
- Detect Changes button – When enabled, it detects any code changes made to the loaded modules.
- Reload – Reloads the loaded modules and applies any changes that have been made.
- Execute buttons – Executes the selected sequence.
git clone git@github.com:stfc-aeg/odin-sequencer.git
cd odin-sequencerpython3 -m venv ./odin-sequencer-3.8
source odin-sequencer-3.8/bin/activatepip install -e .[test]Start the ODIN server while in the odin-sequencer directory.
odin_control --config config/odin_sequencer.cfgFollow the instructions in the
odin-sequencer-ui
repository to use the UI components in your own application.
Alternatively, download the test application:
wget https://github.com/stfc-aeg/odin-sequencer-ui/releases/download/<version>/app_build.tgz
tar -xvzf app_build.tgzThen update the static_path entry in your .cfg file to point to the extracted dist/ directory.
You can then access the UI at:
http://<http_addr>:<http_port>
For example:
http://127.0.0.1:8888
Example configuration:
http_port = 8888
http_addr = 127.0.0.1
static_path = distBy default, the modules in the sequences directory under ~/odin-sequencer/src/examples are loaded when the server starts.
To load modules from a different location, change the sequence_location value in ~/odin_sequencer/config/odin_sequencer.cfg.
sequence_location can point either to a directory containing sequence modules or to a single module file.
Call add_context during another adapter's initialize method (see dummy_context.py for an example).
test_device = TestDevice(123)
self.adapters['odin_sequencer'].add_context('test_device', test_device)The context can then be used in a sequence by calling get_context (see example_sequences.py).
dev = get_context('test_device')Long-running sequences can periodically check the value returned by abort_sequence(), which is exposed to every loaded sequence module.
If it returns true, the sequence can terminate cleanly before completion.
See example_sequences.py for an example of an abortable sequence.
Executing sequences can report progress by calling set_progress(current, total).
This function is exposed to every loaded sequence module and allows both the API and UI to display execution progress.
See example_sequences.py for an example.
With the virtual environment activated, navigate to the supervisord directory and start the worker.
cd odin_sequencer/src/odin_sequencer/supervisord
supervisord -c supervisord.conf || supervisorctl -c supervisord.conf start celeryNavigate to the scripts directory, list the remote workers in workers.txt, update the configuration at the top of start_worker.sh, and then run:
cd scripts
sh start_worker.shNavigate to the scripts directory, list the remote workers in workers.txt, update the configuration at the top of stop_worker.sh, and then run:
cd scripts
sh stop_worker.shEnsure the process queue adapter is loaded in odin_sequencer.cfg:
[adapter.process_queue_context]
module = odin_sequencer.process_queue_context.ProcessQueueContextAdapterAdd processing tasks to tasks.py:
def add(x, y):
return x + yThe process_writer context can then be used within a sequence to submit tasks using run() or group().
queue = get_context('process_writer')
queue.run('add', True, 4, 3)
queue.group('add', True, range(10), 3)
output = queue.run('add', False, 4, 3)
result = output.get()Runs a single task.
Parameters:
str— Task function name.bool—Trueif the return value is not required.- Remaining arguments are passed directly to the task function.
Runs a group of tasks.
Parameters:
str— Task function name.bool—Trueif the return value is not required.list— Values to iterate over for one argument.- Remaining arguments are passed directly to the task function.
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.