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 will detect any code changes that have been made to the loaded modules.
- Reload - When clicked, it will reload the loaded modules and any changes that have been made to them will be applied.
- Execute buttons - When clicked, it will execute the sequence.
$ git clone [email protected]:stfc-aeg/odin-sequencer.git
$ cd odin-sequencer
$ python3 -m venv ./odin-sequencer-3.8
$ source odin-sequencer-3.8/bin/activate
$ pip install -e .[test]
$ odin_server --config config/odin_sequencer.cfg
By default, the modules located inside the sequences
directory in ~/odin-sequencer/src/examples
are loaded when the server is started. If you want to load modules from a different directory, then you will need to change the sequence_location
value inside the odin_sequencer.cfg
file located in ~/odin_sequencer/config
. Modules get loaded into the manager when the server is started if there are any modules in the directory specified. The sequence_location
value does not necessarily have to point to a directory but it can point to a single module file too.
test_device = TestDevice(123)
self.adapters['odin_sequencer'].add_context('test_device', test_device)
The context can now be used in a sequence by calling get_context
(see example_sequences.py for an example)
dev = get_context('test_device')
Long-running sequences can choose to check the value of the abort_sequence()
function, which is
exposed to every loaded sequence module. If true the sequence can be cleanly terminated early.
(See example_sequences.py for an example of an abortable sequence.)
Executing sequences can report progress to the user by calling the set_progress
function,
which is exposed to every loaded sequence module. This takes two arguments reporting the current
and total steps in the sequence. This is used by the API and UI to display progress. (See
example_sequences.py for an example.)
$ cd odin_sequencer/src/odin_sequencer/supervisord
$ supervisord -c supervisord.conf || supervisorctl -c supervisord.conf start celery
Navigate to the scripts directory, list the remote works in workers.txt, update the config at the start of start_worker.sh, and then run the script
$ cd scripts
$ sh start_worker.sh
Navigate to the scripts directory, list the remote works in workers.txt, update the config at the start of stop_worker.sh, and then run the script
$ cd scripts
$ sh stop_worker.sh
[adapter.process_queue_context]
module = odin_sequencer.process_queue_context.ProcessQueueContextAdapter
def add(x, y):
return x + y
The process_writer context can then be loaded during a sequence to add tasks to queue 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()
run
allows for a single task to be run- Parameters:
String
task function nameBoolean
True if the result from the function doesn't need to be returned- arguments for the task function
group
allows for a group of task to be run- Parameters:
String
task function nameBoolean
True if the result from the function doesn't need to be returnedList
list of values of the argument that is to be iterated over- other arguments for the task function
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.