glasgowcompbio / vimms

A programmable and modular LC/MS simulator in Python
MIT License
19 stars 6 forks source link

Added a task manager to manage the number of custom scans being sent #200

Closed joewandy closed 3 years ago

joewandy commented 3 years ago

Fixes for issue #199.

The following PR https://github.com/sdrogers/vimms-fusion/pull/23 allows us to send multiple new custom scan commands after a scan has been received, but we need a way to manage the number of scans we're sending. According to what Thermo said:

New custom scans can always be "sent" to the instrument, the instrument will enqueue them if it has space (I forget the size of the queue, but it is 10-100 in size about,). If it doesn't have the space, it will overwrite the oldest scan in the queue (i.e., it uses a circular buffer). I don't think there is user-visible message if that occurs, I know I had a log print in there to log when that happens.

To ensure that we stay within the limit of the queue, I've added a TaskManager class that tracks (1) current_tasks: the number of current outgoing tasks to be sent, and (2) pending_tasks: the number of pending tasks that have been sent but not received yet.

Currently current_tasks is stored in a list, but it should be possible in the future to replace that with a priority queue, allowing higher priority tasks to be moved forward and sent first.