Hi Zak,
Yes that is actually a problem that BLACS will sit in manual mode and so the plugin callback won't be executed. So I would like to share our hacky current solution. We run a separate python script which keeps sending some query strings to BLACS. This is possible because BLACS is running a server. Then we modify BLACS code to execute a function once we receive specific strings. This function has the code to check the whether BLACS is paused, restart devices etc. I also put some boilerplate code below in case someone else finds it useful.
So we have a script that sends query strings to BLACS. Its code looks like:
****************************
import blacs
blacs.send_query_string(query_string = 'restart_all_devices')
****************************
Then in the __init__.py file of BLACS we define the function send_query_string():
****************************
def send_query_string(host='localhost', port=42517, timeout=5, query_string = 'get_queue_status'):
return zmq_get(port, host, query_string, timeout)
****************************
Next we add/edit some code in the class ExperimentServer(ZMQServer) of the __main__.py file of BLACS.
****************************
def handler(self, h5_filepath=None):
if h5_filepath in ['get_queue_status','restart_all_devices']:
return self.resolve_external_request(h5_filepath)
print(h5_filepath)
message = self.process(h5_filepath)
return message
@inmain_decorator(wait_for_return=True)
def resolve_external_request(self,query_string):
if query_string == 'get_queue_status':
return app.queue.manager_paused
if query_string == 'restart_all_devices':
app.tablist['intermediate_device'].restart()#Put the name of the device you want to restart
return 'restarted'
return 'Hello'
****************************
So we misuse the 'h5_filepath' argument of the handler function to check if it matches any of the predefined query strings. If yes, a function called resolve_external_request() is executed which can perform actions depending on the string received. This function has access to BLACS object app so it can access the queue and devices as the object attributes. Also note that this function needs to be run in the main thread so it has the @inmain_decorator(wait_for_return=True) decorator.
Regards,
Rohit Prasad Bhatt